com.incesoft.botplatform.sdk.support
Class DefaultRobotSession

java.lang.Object
  extended by com.incesoft.botplatform.sdk.support.DefaultRobotSession
All Implemented Interfaces:
RobotSession

public class DefaultRobotSession
extends java.lang.Object
implements RobotSession

Author:
LiBo

Field Summary
 
Fields inherited from interface com.incesoft.botplatform.sdk.RobotSession
OPEN_MODE_CONV_OPEN, OPEN_MODE_ROBOT, OPEN_MODE_TIMEOUT, OPEN_MODE_UNKONW
 
Constructor Summary
DefaultRobotSession(DefaultRobotServer server)
           
DefaultRobotSession(DefaultRobotServer server, java.lang.String robotId, RobotUser user, java.lang.String sessionID)
           
 
Method Summary
 void addUser(RobotUser user)
           
 void close()
          Close this session.
 RobotMessage createMessage()
          Create a message
 java.lang.Object getAttribute(java.lang.String name)
          Returns the object bound with the specified name in this session, or null if no object is bound under the name.
 java.util.Iterator<java.lang.String> getAttributeNames()
          Returns an Iterator of String objects containing the names of all the objects bound to this session
 int getOpenMode()
          Get the open mode of session
 java.lang.String getRobot()
          Get the robot account(MSN Passport) associated with this session
 java.lang.String getSessionID()
           
 RobotUser getUser()
          Get a user's reference in session
 RobotUser getUser(java.lang.String userid)
          Get a user's reference in session
 int getUserCount()
           
 java.util.Collection<RobotUser> getUsers()
          Get a users' collection in session
 void inviteUser(java.lang.String user)
          Invite a user into the current conversation.
 boolean isActivityOpened()
          Check whether the activity window opened.
 boolean isClosed()
          Check whether the session is closed.
 java.lang.Object removeAttribute(java.lang.String name)
          Removes the object bound with the specified name from this session.
 RobotUser removeUser(java.lang.String user)
           
 void send(RobotMessage message)
          Send RobotMessage
 void send(java.lang.String message)
          Send plain text message
 void sendActivity(int appid, java.lang.String appname, java.lang.String data)
          Send activity data to the MSN Activity window.
 void sendActivity(java.lang.String data)
          Show the content of network resource in MSN Activity window
 void sendActivity(java.lang.String data, java.lang.String friendlyName)
          Show the content of network resource in MSN Activity window
 void sendFile(java.lang.String uri)
          Send a file
 void sendFile(java.lang.String uri, java.lang.String friendlyName)
          Send a file
 void sendFileAcceptance(java.lang.String transferId, java.lang.String saveUrl)
          Accept a file transfer request, and a url should be specified for saving the file data.
 void sendFileCancellation(java.lang.String transferId)
          Cancel a file transfer.
 void sendFileRejection(java.lang.String transferId)
          Reject a file transfer request.
 void sendInk(byte[] inkData)
          Send a ink message
 void sendNudge()
          Send nudge
 void sendTyping()
          Send a typing infomation which will be presented on the bottom of the conversation panel
 void sendVoiceclip(java.lang.String uri)
          Send a voice clip
 void sendWebcam(java.lang.String serverIP, int serverPort, int recipientid, int sessionid)
          Send webcam Once the connection is established, the client that connected to the other peer should authenticate himself with sending the message (no header, no nothing) : "recipientid=X&sessionid=Y\r\n\r\n" The other peer should then send (if correctly authenticated) the message "connected\r\n\r\n" The connecting peer should also send "connected\r\n\r\n" From this point the connection is done and The connecting peer is authenticated Subsequently, the server may send the encoded data of the webcam in mimic format
 void sendWink(java.lang.String uri)
          Send a msn default wink
 void sendWink(java.lang.String uri, java.lang.String stamp)
          Send a customized wink
 void setActivityOpened(boolean activityOpened)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
          Binds an object to this session, using the name specified.
 void setClosed(boolean closed)
           
 void setOpenMode(int openMode)
           
 void setRobot(java.lang.String robot)
           
 void setSessionID(java.lang.String sessionID)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRobotSession

public DefaultRobotSession(DefaultRobotServer server)

DefaultRobotSession

public DefaultRobotSession(DefaultRobotServer server,
                           java.lang.String robotId,
                           RobotUser user,
                           java.lang.String sessionID)
Method Detail

send

public void send(java.lang.String message)
          throws RobotException
Description copied from interface: RobotSession
Send plain text message

Specified by:
send in interface RobotSession
Throws:
RobotException

createMessage

public RobotMessage createMessage()
Description copied from interface: RobotSession
Create a message

Specified by:
createMessage in interface RobotSession
Returns:
RobotMessage RobotMessage

getUser

public RobotUser getUser()
Description copied from interface: RobotSession
Get a user's reference in session

Specified by:
getUser in interface RobotSession
Returns:
RobotUser RobotUser

addUser

public void addUser(RobotUser user)

removeUser

public RobotUser removeUser(java.lang.String user)

getUserCount

public int getUserCount()

getUser

public RobotUser getUser(java.lang.String userid)
Description copied from interface: RobotSession
Get a user's reference in session

Specified by:
getUser in interface RobotSession
Parameters:
userid - user id
Returns:
RobotUser RobotUser

getUsers

public java.util.Collection<RobotUser> getUsers()
Description copied from interface: RobotSession
Get a users' collection in session

Specified by:
getUsers in interface RobotSession
Returns:
Collection

isClosed

public boolean isClosed()
Description copied from interface: RobotSession
Check whether the session is closed. If session is closed, you cannot send any messages.

Specified by:
isClosed in interface RobotSession

setClosed

public void setClosed(boolean closed)

getOpenMode

public int getOpenMode()
Description copied from interface: RobotSession
Get the open mode of session

Specified by:
getOpenMode in interface RobotSession
Returns:
openmode. 0 - Unknown; 1 - Indicates that user opens a conversation window; 2 - Indicates that session timeout and then reconnects

setOpenMode

public void setOpenMode(int openMode)

getRobot

public java.lang.String getRobot()
Description copied from interface: RobotSession
Get the robot account(MSN Passport) associated with this session

Specified by:
getRobot in interface RobotSession
Returns:
robot account.

setRobot

public void setRobot(java.lang.String robot)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: RobotSession
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

Specified by:
setAttribute in interface RobotSession
Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: RobotSession
Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Specified by:
getAttribute in interface RobotSession
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface: RobotSession
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.

Specified by:
removeAttribute in interface RobotSession
Parameters:
name - the name of the object to remove from this session
Returns:
the object with the specified name

getAttributeNames

public java.util.Iterator<java.lang.String> getAttributeNames()
Description copied from interface: RobotSession
Returns an Iterator of String objects containing the names of all the objects bound to this session

Specified by:
getAttributeNames in interface RobotSession
Returns:
an Iterator of String objects specifying the names of all the objects bound to this session

isActivityOpened

public boolean isActivityOpened()
Description copied from interface: RobotSession
Check whether the activity window opened.

Specified by:
isActivityOpened in interface RobotSession

setActivityOpened

public void setActivityOpened(boolean activityOpened)

send

public void send(RobotMessage message)
          throws RobotException
Description copied from interface: RobotSession
Send RobotMessage

Specified by:
send in interface RobotSession
Parameters:
message - RobotMessage
Throws:
RobotException

sendNudge

public void sendNudge()
               throws RobotException
Description copied from interface: RobotSession
Send nudge

Specified by:
sendNudge in interface RobotSession
Throws:
RobotException

sendActivity

public void sendActivity(java.lang.String data)
                  throws RobotException
Description copied from interface: RobotSession
Show the content of network resource in MSN Activity window

Specified by:
sendActivity in interface RobotSession
Parameters:
data - network resource to be shown (generally are webpages or pictures)
Throws:
RobotException

sendActivity

public void sendActivity(java.lang.String data,
                         java.lang.String friendlyName)
                  throws RobotException
Description copied from interface: RobotSession
Show the content of network resource in MSN Activity window

Specified by:
sendActivity in interface RobotSession
Parameters:
data - network resource to be shown (generally are webpages or pictures)
friendlyName - friendly name which represents the network resource in the activity invitation
Throws:
RobotException

sendTyping

public void sendTyping()
                throws RobotException
Description copied from interface: RobotSession
Send a typing infomation which will be presented on the bottom of the conversation panel

Specified by:
sendTyping in interface RobotSession
Throws:
RobotException

sendFile

public void sendFile(java.lang.String uri)
              throws RobotException
Description copied from interface: RobotSession
Send a file

Specified by:
sendFile in interface RobotSession
Parameters:
uri - unique name of the resource pre-uploaded to BOTPLATFORM and verified by BOTPLATFORM
Throws:
RobotException

sendFile

public void sendFile(java.lang.String uri,
                     java.lang.String friendlyName)
              throws RobotException
Description copied from interface: RobotSession
Send a file

Specified by:
sendFile in interface RobotSession
Parameters:
uri - unique name of the resource pre-uploaded to BOTPLATFORM and verified by BOTPLATFORM
friendlyName - friendly name which represents the file in the file transfer invitation
Throws:
RobotException

sendFileAcceptance

public void sendFileAcceptance(java.lang.String transferId,
                               java.lang.String saveUrl)
                        throws RobotException
Description copied from interface: RobotSession
Accept a file transfer request, and a url should be specified for saving the file data.

Specified by:
sendFileAcceptance in interface RobotSession
Parameters:
transferId - id of the current file transfer.
saveUrl - a url to receive a HTTP POST request to get the data of the file.
Throws:
RobotException

sendFileRejection

public void sendFileRejection(java.lang.String transferId)
                       throws RobotException
Description copied from interface: RobotSession
Reject a file transfer request.

Specified by:
sendFileRejection in interface RobotSession
Parameters:
transferId - id of the current file transfer.
Throws:
RobotException

sendFileCancellation

public void sendFileCancellation(java.lang.String transferId)
                          throws RobotException
Description copied from interface: RobotSession
Cancel a file transfer.

Specified by:
sendFileCancellation in interface RobotSession
Throws:
RobotException

sendInk

public void sendInk(byte[] inkData)
             throws RobotException
Description copied from interface: RobotSession
Send a ink message

Specified by:
sendInk in interface RobotSession
Parameters:
inkData - data of the ink message.
Throws:
RobotException

sendWink

public void sendWink(java.lang.String uri)
              throws RobotException
Description copied from interface: RobotSession
Send a msn default wink

Specified by:
sendWink in interface RobotSession
Parameters:
uri - unique name of the resource pre-uploaded to BOTPLATFORM and verified by BOTPLATFORM
Throws:
RobotException

sendWink

public void sendWink(java.lang.String uri,
                     java.lang.String stamp)
              throws RobotException
Description copied from interface: RobotSession
Send a customized wink

Specified by:
sendWink in interface RobotSession
Parameters:
uri - unique name of the resource pre-uploaded to BOTPLATFORM and verified by BOTPLATFORM
stamp - base64 encoded signature of the file.It is a S/MIME signature of the Base64 encoded hash of the Content cabinet file and is signed by the MSN Content Authority.
Throws:
RobotException

sendVoiceclip

public void sendVoiceclip(java.lang.String uri)
                   throws RobotException
Description copied from interface: RobotSession
Send a voice clip

Specified by:
sendVoiceclip in interface RobotSession
Parameters:
uri - unique name of the resource pre-uploaded to BOTPLATFORM and verified by BOTPLATFORM
Throws:
RobotException

sendWebcam

public void sendWebcam(java.lang.String serverIP,
                       int serverPort,
                       int recipientid,
                       int sessionid)
                throws RobotException
Description copied from interface: RobotSession
Send webcam Once the connection is established, the client that connected to the other peer should authenticate himself with sending the message (no header, no nothing) : "recipientid=X&sessionid=Y\r\n\r\n" The other peer should then send (if correctly authenticated) the message "connected\r\n\r\n" The connecting peer should also send "connected\r\n\r\n" From this point the connection is done and The connecting peer is authenticated Subsequently, the server may send the encoded data of the webcam in mimic format

Specified by:
sendWebcam in interface RobotSession
Parameters:
serverIP - webcam resource server IP address
serverPort - webcam resource server port
recipientid - the authentication info, should be between 100 and 199
sessionid - the authentication info, should be between 9000 and 9999
Throws:
RobotException

inviteUser

public void inviteUser(java.lang.String user)
                throws RobotException
Description copied from interface: RobotSession
Invite a user into the current conversation.

Specified by:
inviteUser in interface RobotSession
Throws:
RobotException

sendActivity

public void sendActivity(int appid,
                         java.lang.String appname,
                         java.lang.String data)
                  throws RobotException
Description copied from interface: RobotSession
Send activity data to the MSN Activity window.

Specified by:
sendActivity in interface RobotSession
Parameters:
appid - id of the MSN Activity
appname - name of the MSN Activity
data - network resource to be shown (generally are webpages or pictures)
Throws:
RobotException

close

public void close()
           throws RobotException
Description copied from interface: RobotSession
Close this session.

Specified by:
close in interface RobotSession
Throws:
RobotException

getSessionID

public java.lang.String getSessionID()

setSessionID

public void setSessionID(java.lang.String sessionID)