Packageorg.idream.pomelo
Classpublic class Pomelo
InheritancePomelo Inheritance flash.events.EventDispatcher

Pomelo - Flash - TCP



Public Properties
 PropertyDefined By
  heartbeat : int
Pomelo
  message : IMessage
Pomelo
Public Methods
 MethodDefined By
  
Pomelo(useWeakReference:Boolean = true)
Pomelo
  
beat():void
向服务器发送一次心跳事件
Pomelo
  
destroy():void
if you use new Pomelo(false) (not using weak reference) don't forget to call destroy()
Pomelo
  
disconnect():void
与服务器主动断开连接
Pomelo
  
[static]
Pomelo
  
init(host:String, port:int, user:Object = null, callback:Function = null, timeout:int = 8000):void
初始化客户端,并尝试连接服务器
Pomelo
  
notify(route:String, msg:Object):void
向服务器发送数据
Pomelo
  
on(route:String, callback:Function):void
响应服务器的推送事件
Pomelo
  
request(route:String, msg:Object, callback:Function = null):void
向服务器请求数据
Pomelo
Events
 Event Summary Defined By
  Pomelo
  Pomelo
  Pomelo
  Pomelo
  Pomelo
Public Constants
 ConstantDefined By
  info : Object
[static]
Pomelo
  requests : Dictionary
[static]
Pomelo
Property Detail
heartbeatproperty
public var heartbeat:int

messageproperty 
message:IMessage


Implementation
    public function get message():IMessage
    public function set message(value:IMessage):void
Constructor Detail
Pomelo()Constructor
public function Pomelo(useWeakReference:Boolean = true)



Parameters
useWeakReference:Boolean (default = true)
Method Detail
beat()method
public function beat():void

向服务器发送一次心跳事件

destroy()method 
public function destroy():void

if you use new Pomelo(false) (not using weak reference) don't forget to call destroy()

disconnect()method 
public function disconnect():void

与服务器主动断开连接

getIns()method 
public static function getIns():Pomelo

Returns
Pomelo
init()method 
public function init(host:String, port:int, user:Object = null, callback:Function = null, timeout:int = 8000):void

初始化客户端,并尝试连接服务器

Parameters

host:String
 
port:int
 
user:Object (default = null) — 客户端与服务器之间的自定义数据
 
callback:Function (default = null) — 当连接成功会调用此方法
 
timeout:int (default = 8000)

notify()method 
public function notify(route:String, msg:Object):void

向服务器发送数据

Parameters

route:String
 
msg:Object

on()method 
public function on(route:String, callback:Function):void

响应服务器的推送事件

Parameters

route:String — 推送事件的名称
 
callback:Function — 当服务器发生推送时会调用此函数

request()method 
public function request(route:String, msg:Object, callback:Function = null):void

向服务器请求数据

Parameters

route:String
 
msg:Object
 
callback:Function (default = null) — 服务器返回数据时会回调

Event Detail
close Event
Event Object Type: flash.events.Event

handshake Event  
Event Object Type: org.idream.pomelo.PomeloEvent

ioError Event  
Event Object Type: flash.events.IOErrorEvent

kicked Event  
Event Object Type: org.idream.pomelo.PomeloEvent

securityError Event  
Event Object Type: flash.events.SecurityErrorEvent

Constant Detail
infoConstant
public static const info:Object

requestsConstant 
public static const requests:Dictionary