Provides a programmatic interface to the SCLOrkChat-User-Guide system. Used by SCLOrkChat, the chat graphical user interface, and could also be used by other programs to make bots. The primary usage of the object revolves around providing callback functions to the client on the onConnected, onMessageReceived, and onUserChanged accessors, and responding to server events from there.
Create a new SCLOrkChatClient object, initialize and return it.
serverAddress |
A string with either an IP address or a resolvable hostname providing the location for a running instance of SCLOrkChatServer. |
serverPort |
The port provided to the running SCLOrkChatServer: bindPort. |
listenPort |
The SCLOrkWire port to listen to responses from the server on. Clients listen on only one port to enable multiple clients to run on the same IP address/machine. |
A new SCLOrkChatClient object.
Acessor method for the client's current map of userId keys to name values.
A Dictionary with integer userIds as keys and string nicknames as values.
Connect to the server at the address specificed in new. Will call the function at onConnected with results of the connection attempt.
name |
The nickName to associate with this client. |
Function the client will call upon receipt of any chat messages from the server. The client will call the function with a single argument, a SCLOrkChatMessage object containing the deserialized message.
Serializes the provided SCLOrkChatMessage object and sends it to the server, for sending to the targeted recipients on the client's behalf.
chatMessage |
A SCLOrkChatMessage object. |
Access, or change the current name associated with this client to a new string value.
newName |
The new string name to associate with this client. |
Function the client will call after applying any updates to its userDictionary. The client will call the provided function with four arguments: type, userId, name, oldName. The type argument is an enumeration documented at SCLOrkChat-OSC-Command-Reference: changeType enumeration. The userId and name arguments are the id and name associated with the client that is changing. Lastly the oldName argument is only valid if the type values is \rename, in which case the client will supply the old name the user was going by, and the new name will be in name.
Will automatically call disconnect if the client is connected to the server. Then unbinds all listener functions and destroys the object.
Function the client will call after any change in connection status. The client will call the provided function with a single boolean argument, if true the client has successfully connected, if false the client is disconnected.
Accessor method for the integer userId associated with this particular client.
If connected to the server the client will send a sign-out message to the server. It will then call onConnected with a false value in the argument to indicate disconnection has occurred.