OzWebClient.connect(serverAddress,
token, properties) method

It is used to connect the webclient to the Ozeki Phone System. To connect to it you need to provide the IP address of Ozeki Phone System XE and a security token that will help in the authentication.

Parameters

serverAddress: It is a mandatory string parameter. It is the server address of Ozeki Phone System. e.g. "192.168.115.131" As a default it is connected to port number 7779 which is the default mediagateway port.

token: It is a mandatory string parameter. Here you need to put the token what you get from the Ozeki Phone System. You can learn how to genereate security token with the help of this page.
The installed Webphone Outsidelines or Extensions contain a security token by default, so you can connect to the Ozeki Phone System with them.

properties: It is an object, it is an optional parameter. It can be any object you want it to be. The other clients receive this object when a client connects or disconnects. They receive it through an onClientStateChanged event. For example you could add attributes to the object like a nickname and a link to an avatar to make a chatroom. You can see that the purpose of this object is that a webclient can share any information about itself to the other webclients.
If you use Webphone Extension to login, you can add the password of the extension with this parameter.

Method usage example

In this example we will register to the onConnectionStateChanged event and try to connect to 1500 Webphone extension of the Ozeki Phone System on localhost. The result of the connection will be shown on the console log. There are four kinds of connection states: "ACCESS_GRANTED", "ACCESS_DENIED", "CONNECTION_FAILED", "CONNECTION_CLOSED" (Code example 1).

var clientProperties = {}; //makes on object
clientProperties.Nickname = "John";
clientProperties.Avatar = "http://myavatar.com/1.jpg"; 
clientProperties.Password = "12345678"; //password of the Webphone Extension 

//registers to the onConnectionStateChanged event
OzWebClient.onConnectionStateChanged(connectionStateChanged); 
//connects to the 1500 extension of Ozeki Phone System 
OzWebClient.connect("localhost", "1500", clientProperties); 

function connectionStateChanged(state) {
   console.log(state); //shows the state of the connection on the console log
}
	
Code example 1 - OzWebClient.connect(serverAddress, token, properties) method example

In this example we will register to the onConnectionStateChanged event and try to connect to Ozeki Phone System on localhost with the help of a security token. (Code example 2).

//registers to the onConnectionStateChanged event
OzWebClient.onConnectionStateChanged(connectionStateChanged); 
//connects to the Ozeki Phone System 
OzWebClient.connect("localhost", "myGeneratedSecurityToken"); 

function connectionStateChanged(state) {
   console.log(state); //shows the state of the connection on the console log
}
	
Code example 2 - OzWebClient.connect(serverAddress, token) method example

More information