dgurkaynak / nodeshout

Native libshout bindings for node.js
MIT License
50 stars 20 forks source link

Disconnected event #13

Closed 0xAnakin closed 1 year ago

0xAnakin commented 1 year ago

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

dgurkaynak commented 1 year 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 1 year 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.