dgurkaynak / nodeshout

Native libshout bindings for node.js
MIT License
49 stars 19 forks source link

Disconnected event #13

Closed 0xAnakin closed 11 months ago

0xAnakin commented 11 months ago

Is there a way to get notified when you get disconnected from the icecast server?

dgurkaynak commented 11 months ago

Hey @0xAnakin, sorry for late response.

I think I've found it. Both shout.open(), shout.send() and shout.setMetadata() methods return a code indicating whether the operation is successful or not. You can see what method can return which codes from the original libshout docs.

If disconnected, shout.send() returns -2 which is nodeshout.ErrorTypes.NOCONNECT. You can catch the disconnection event like this.

0xAnakin commented 11 months ago

Yes I did the same thing after each send I'm checking if the data have been sent otherwise i fire an error event.