Javascript API


Functions

Name Description
getParameters():object Return object of properties from flashphoner.xml file
login(username:String,password:String):int Log in to flashphoner_server, returned 0 - if 'username' is success, 1 - if 'username' is wrong.
Format 'username': "sip:[email protected]"
loginByToken(token:String = null):void
Log in to flashphoner_server by token which use in http provider
logoff():void
Log off current user
getInfoAboutMe():ModelLocator
Get info about logged user (login,password,sipAddress,sipPort,visibleName)
sendMessage(to:String, body:String, contentType:String):void
Send instance message to user with login 'callee'
sendInfo(obj):void Force server send SIP INFO request to second party. 

There are parameters: 
obj.callId - call id  
obj.contentType - content type os sent message ("application/dtmf", "application/xml" etc)
obj.body - message body
call(callee:String, visibleName:String, isVideoCall:Boolean = true, inviteParameters:Object = null):int Call to user with login 'callee',
Returned 0 - if 'callee' is success, 1 - if 'callee' is wrong.
Format 'callee': "sip:[email protected]" or sip login or phone number or null. if 'callee' is null then 'callee' equals parameter of file flashphoner.properties from server side.

inviteParameters - parameters for invite request. Example:

Define:
testInviteParameter['param1'] = "value1";
testInviteParameter['param2'] = "value2";

In request:
INVITE sip:[email protected];param1=value1;param2=value2 SIP/2.0
callByToken(token:String, isVideoCall:Boolean = true, inviteParameters:Object = null):int
Call to user by 'token', this token will sent over url 'get_callee_url', which you can specify in file 'flashphoner-client.properties' on server
Value another parameters see in method 'call'
hangup(callId:String):void Hangup current call
answer(callId:String, isVideoCall:Boolean = false):void
Answer on incomming call
sendDTMF(callId:String,dtmf:String):void
Send DTMF command
setStatusHold(callId:String,isHold:Boolean = true):void
Hold/Unhold for the call
transfer(callId:String,target:String):void
Transfer call  to the user with login 'target'
setSendVideo(isSend:Boolean):void
Start/Stop sending video
getMicVolume():int Get current microphone volume
setMicVolume(volume:int):void Set volume current microphone
getVolume():int
Get volume of current speaker
setVolume(volume:int):void
Set volume of current speaker
isMuted():int
Check access to the microphone.
Return
0 - if microphone does no exist
-1 - if has access
1 - if has not access
getMicropones():Array Get array of names all microphones
setMicrophone(name:String):void{} Set new microphone by name
getCameras():Array Get array of names all cameras
setCamera(name:String):void{} Set new camera by name
getCurrentCall():Call
Get current call in TALK state
setCookie(key:String,value:String):void Set cookie for save info
getCookie(key:String):String Get cookie for load info
getVersion():String Get version of client and server. Version of the server shows if user logged
viewVideo():void Attach current camera and view outgoing and incoming video
viewAccessMessage():void
View window for access to devices
changeRelationMyVideo(relation:Number):void
Change relation of height to width
Notify functions  
notifyCloseConnection():void Close connection server
notifyConnected():void Application connected to the server
notifyRegistered():void User registered on sip server
notifyCallbackHold(call:Call,isHold:Boolean):void
Callback for operation - setStatusHold(callId:String,isHold:Boolean = true):void
notify(call:Call):void Notify state of call
notifyCost(call:Call,cost:Number):void Notify cost of current call
notifyBalance(balance:Number):void Notify balance of user
notifyError(error:String):void Notify error with error code
notifyVideoFormat(call:Call):void Notify video height and width of incoming and outgoing video
notifyOpenVideoView(isViewed:Boolean):void
Notify open video view, because received incoming video stream
notifyMessage(messageObject:Object):void Notify of the new instance message
notifyAddCall(call:Call):void Notify add new call in array
notifyRemoveCall(call:Call):void Notify remove call from array
addLogMessage(message:String):void
Add log message (example: for warnings)
notifyVersion(version:String):void
Notify change version
notifyFlashReady():void Notify if swf file and flashphoner.xml loaded

Objects and properties

Call

Property Desсription
id:String; Сall identifier
state:String; Call status (TALK,RING,HOLD...)
iHolded:Boolean = false; Is held call
callee:String; User, which created call
caller:String; User, which answered call
visibleNameCallee:String; Visible name of callee
visibleNameCaller:String; Visible name of caller
playerVideoHeight:int; Height of video in player
playerVideoWidth:int; Width of video in player
streamerVideoHeight:int; Height of video in streamer
streamerVideoWidth:int; Width of video in player
timeOfCall:int = 0; Current time of call
anotherSideUser:String; A user on the other side
incoming:Boolean = false; Is incoming call
isVideoCall:Boolean = false; Is video call
sip_state:String; Sip state of current call.
Returns strings like 180, 200, 403 etc 

Constants

ErrorCodes

Name Description
AUTHENTICATION_FAIL Registration on sip-server is fail.
This is response from the server about
an unsuccessful registration under sent
username and password.
USER_NOT_AVAILABLE User not available in sip server
TOO_MANY_REGISTER_ATTEMPTS User with name many register
LICENSE_RESTRICTION License of Flashphoner is not valid
LICENSE_NOT_FOUND
License of Flashphoner not found
INTERNAL_SIP_ERROR Unknown sip error
CONNECTION_ERROR Connection to the server fail
REGISTER_EXPIRE Registration on sip server is expired
PARAMETERS_IS_NOT_INITIALIZED
Parameters from file 'flashphoner.xml' is not red. * throw when execute Flash_API.getParameters()
Parameters from file 'flashphoner.xml' is not red.
throw when execute Flash_API.getParameters()
SIP_PORTS_BUSY All sip ports on flashphoner-server is busy
MEDIA_PORTS_BUSY All media sip ports on flashphoner-server is busy
WRONG_SIPPROVIDER_ADDRESS Flashphoner server can not connect with sip provider server.

Call states

Name Description
STATE_RING Start ring of call
STATE_TALK Talk command for send and receive audio and video
STATE_FINISH Finish of current call
STATE_BUSY Busy of current call
STATE_HOLD
Hold of current call

Labels

javascript_api javascript_api Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.