OzWebClient.onClientStateChanged event
This event occurs when another client connects or disconnects to Ozeki Phone System. As a parameter it gets the name of a function that will run when the event occurs. This function will get an object as an input, that has three attributes:
Callback method input parameters
phoneNumber: Type: string. It is the phone number of the client which caused the event e.g. "Qdb3W"
status: Type: string. It is the status of the client. It can get these two values: "ONLINE", "OFFLINE"
an object: It is the object received from the properties attribute of the OzWebClient.connect method. This object can contain the displayed nickname for a webchat or a link to download an avatar picture or anything you can imagine. You can see that the purpose of this object is that a client can share any information about itself to the other clients.
Event usage example
To demonstrate how this works we will use two webclients. The first one will already be connected to the webphone outside line, this one will wait for the onClientStateChanged event. The other one will connect later on and send its webclient properties to the first webclient. These properties will be a chat nickname and a link to an avatar picture.
The client who waits for the other to connect, registers to the onClientStateChanged event. When the other webclient connects, this event will occur and the clientStateChanged function will be called. The clientInfo input parameter will be the object the other webclient sends. This object contains a phoneNumber, a status, a nickname and a link to an avatar (Code example 1).
var avatarlink; //registers to the onClientStateChanged event OzWebClient.onClientStateChanged(clientStateChanged); function clientStateChanged(ClientInfo) { console.log(ClientInfo.nickname + " is " + ClientInfo.status);// "John is ONLINE" avatarlink = ClientInfo.avatar; // link to the avatar }
Then the second webclient connects to a webphone outside line and sends its properties (nickname,avatar) ,too. The phone number and the status are automatically sent out (Code example 2).
var clientProperties = {}; //makes an object clientProperties.nickname = "John"; clientProperties.avatar = "http://myavatar.com/1.jpg"; //connects to the webphone outside line and sends the properties to the other clients OzWebClient.connect("localhost", "Webphone1", clientProperties);
More information
- JavaScript connect method
- JavaScript createCall method
- JavaScript checkWebPhoneState method
- JavaScript disconnect method
- JavaScript method initiates a call history query request
- JavaScript onCallHistoryInfoReceived method
- JavaScript onClientStateChanged event
- JavaScript onConnectionStateChanged event
- JavaScript OzWebClient.onErrorOccured event
- JavaScript OzWebClient.onIncomingCall event
- OzWebClient.onSessionCreated event
- JavaScript OzWebClient.onSessionClosed event