sfs2x客户端笔记

SFS主要是通过 SmartFox类去发送各种请求,以及监听它的各种SFSEvent来进行对应操作常用的操作以及对应的事件有

进行服务器登录连接

方法connect

对应事件:

CONNECTION

The Event notifies the result of a connection attempt.

CONNECTION_LOST

The Event notifies the disconnection from the Server.

CONNECTION_RESUME

The Event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd.CONNECTION_RETRY

The Event notifies a temporary disconnection from the Server followed by an immediate attempt to reconnect.

当用户与服务器通过connect建立连接之后便是执行正常的登录(校验)操作

发送请求LoginRequest

对应事件:LOGIN

The Event is dispatched in response to a login request.

LOGIN_ERROR

The Event is dispatched in response to a failed login request.

登录成功之后,用户将会被存放在服务器对应的ZONE中(zone的选择由LoginRequest的参数来实现)接下来将是创建或者直接进入该ZONE中的某一个房间

发送请求CreateRoomRequest

对应事件:ROOM_ADD

The Event is dispatched when a new Room was created inside the Zone under any of the Room Groups that the User is listening for. 

ROOM_CREATION_ERROR

The Event is dispatched in response to a failed create room request. 

发送请求JoinRoomRequest

对应事件:ROOM_JOIN

The Event is dispatched in response to a JoinRoomRequest.

ROOM_JOIN_ERROR

The Event is dispatched in response to a failed JoinRoomRequest. 

游戏中的数据发生变化主要是房间的数据和用户的数据两种

发送请求SetRoomVariablesRequest

对应事件:ROOM_VARIABLES_UPDATE

The Event is fired in response to a SetRoomVariablesRequest

发送请求SetUserVariablesRequest

对应事件:USER_VARIABLES_UPDATE 

The Event is fired in response to a SetUserVariablesRequest

一般的消息操作,主要分为公聊,私聊,裁判消息和管理员消息,同时还有对象消息

发送请求PublicMessageRequest

对应事件:PUBLIC_MESSAGEThe Event is fired when a User sends a public message. 

发送请求PrivateMessageRequest

对应事件:PRIVATE_MESSAGEThe Event is fired when a User receives a private message. 

发送请求ModeratorMessageRequest

对应事件:MODERATOR_MESSAGE : String 

The Event is fired when a User receives a Moderator message. 

发送请求AdminMessageRequest

对应事件:ADMIN_MESSAGE 

The Event is fired when a User receives an Admin message. 

发送请求ObjectMessageRequest

对应事件:OBJECT_MESSAGE :String

This Event is received when a User has sent an ObjectMessage request

此外,在使用聊了公聊和私聊之外的消息,都要注意MessageRecipientMode这个类,它描述了消息发送的4种方向.

TO_USER:

the message will be sent to the User (passed as the target parameter)

TO_ROOM:

the message will be sent to all Users in the Room (passed as the target parameter)

TO_GROUP:

the message will be sent to all Users in the Room Group (passed as a String in the target parameter)

TO_ZONE:

the message will be sent to all Users in the Zone (target is ignored 

用户离开房间的时候

发送请求LeaveRoomRequest 

对应事件:USER_EXIT_ROOM

The Event is fired whenever a User leaves one of the Rooms where the current User is joined. 

用户断开连接的时候

发送请求LogoutRequest

对应事件:LOGOUT 

The Event is dispatched in response to a logout request. 

层级关系ZONE->ROOM->EXTENSION->ClientRequestHandler

转贴注明注明来自lunastudio.cn

你可能感兴趣的:(SFS2X)