internal void send(PackageType type) { if (this.state != ProtocolState.closed) { this.transporter.send(PackageProtocol.encode(type)); } }
//Invoke by Transporter, process the message internal void processMessage(byte[] bytes) { Package pkg = PackageProtocol.decode(bytes); //Ignore all the message except handshading at handshake stage if (pkg.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { //Ignore all the message except handshading JsonObject data = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(Encoding.UTF8.GetString(pkg.body)); processHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); } else if (pkg.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); pc.processMessage(messageProtocol.decode(pkg.body)); } else if (pkg.type == PackageType.PKG_KICK) { this.close(); pc.getEventManger().InvokeOnEvent(PomeloClient.EVENT_KICK, null); } }
// Invoke by Transporter, process the message public void ProcessMessage(byte[] bytes) { Package pkg = PackageProtocol.Decode(bytes); Loom.DispatchToMainThread(() => { // Ignore all the message except handshading at handshake stage if (pkg.Type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { // Ignore all the message except handshading JsonObject data = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(Encoding.UTF8.GetString(pkg.Body)); this.ProcessHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.Type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.ResetTimeout(); } else if (pkg.Type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.ResetTimeout(); this.pc.ProcessMessage(this.messageProtocol.Decode(pkg.Body)); } else if (pkg.Type == PackageType.PKG_KICK) { this.GetPomeloClient().Kick(); this.Close(); } }); }
//Invoke by Transporter, process the message internal void processMessage(byte[] bytes) { Package pkg = PackageProtocol.decode(bytes); //Ignore all the message except handshading at handshake stage if (pkg.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { //Ignore all the message except handshading JsonNode_Object data = (JsonNode_Object)MyJson.MyJson.Parse(Encoding.UTF8.GetString(pkg.body)); processHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); } else if (pkg.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); pc.processMessage(messageProtocol.decode(pkg.body)); } else if (pkg.type == PackageType.PKG_KICK) { this.getPomeloClient().disconnect(); this.close(); } }
//Invoke by Transporter, process the message internal void processMessage(byte[] bytes) { Package pkg = PackageProtocol.decode(bytes); //Ignore all the message except handshading at handshake stage if (pkg.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { //Ignore all the message except handshading JsonObject data = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(Encoding.UTF8.GetString(pkg.body)); //UnityEngine.Debug.Log (">>PKG_HANDSHAKE: "+data); processHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); //UnityEngine.Debug.Log (">>PKG_HEARTBEAT: "); } else if (pkg.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { //UnityEngine.Debug.Log (">>PKG_DATA: "+KcpTransporter.print(pkg.body)); Message msg = messageProtocol.decode(pkg.body); //UnityEngine.Debug.Log (">>PKG_DATA2: "+(msg==null?"null":msg.type+", "+msg.route+", "+msg.data)); this.heartBeatService.resetTimeout(); pc.processMessage(msg); } else if (pkg.type == PackageType.PKG_KICK) { //UnityEngine.Debug.Log (">>PKG_KICK: "); this.getPomeloClient().disconnect(); this.close(); } }
//Invoke by Transporter, process the message void processMessage(byte[] bytes) { Package pkg = PackageProtocol.decode(bytes); //Ignore all the message except handshading at handshake stage if (pkg.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { //Ignore all the message except handshading JsonData data = LitJson.JsonMapper.ToObject(Encoding.UTF8.GetString(pkg.body)); processHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); } else if (pkg.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); if (messageProcessor != null) { messageProcessor(messageProtocol.decode(pkg.body)); } } else if (pkg.type == PackageType.PKG_KICK) { this.close(); } }
//Invoke by Transporter, process the message internal void processMessage(byte[] bytes) { Package pkg = PackageProtocol.decode(bytes); Trace.TraceInformation("processMessage:" + pkg.type + " " + this.state); //Ignore all the message except handshading at handshake stage if (pkg.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { //Ignore all the message except handshading JsonObject data = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(Encoding.UTF8.GetString(pkg.body)); processHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); } else if (pkg.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); pc.processMessage(messageProtocol.decode(pkg.body)); } else if (pkg.type == PackageType.PKG_KICK) { Trace.TraceInformation("pkg.type == PackageType.PKG_KICK"); this.getPomeloClient().Kick(); this.close(); } }
//Invoke by Transporter, process the message internal void processMessage(byte[] bytes) { Package pkg = PackageProtocol.decode(bytes); //Ignore all the message except handshading at handshake stage if (pkg.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { //Ignore all the message except handshading string pkg_body = Encoding.UTF8.GetString(pkg.body); JsonObject data = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(pkg_body); processHandshakeData(data); this.state = ProtocolState.working; } else if (pkg.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); } else if (pkg.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); Message msg = messageProtocol.decode(pkg.body); pc.processMessage(msg); } else if (pkg.type == PackageType.PKG_KICK) { this.close(); } }
internal void processMessage(byte[] bytes) { Package package = PackageProtocol.decode(bytes); if ((package.type == PackageType.PKG_HANDSHAKE) && (this.state == ProtocolState.handshaking)) { Encoding.UTF8.GetString(package.body); JsonObject msg = (JsonObject)SimpleJson.DeserializeObject(Encoding.UTF8.GetString(package.body)); this.processHandshakeData(msg); this.state = ProtocolState.working; } else if ((package.type == PackageType.PKG_HEARTBEAT) && (this.state == ProtocolState.working)) { this.heartBeatService.resetTimeout(); } else if ((package.type == PackageType.PKG_DATA) && (this.state == ProtocolState.working)) { this.heartBeatService.resetTimeout(); this.pc.processMessage(this.messageProtocol.decode(package.body)); } else if (package.type == PackageType.PKG_KICK) { this.close(); } }
internal void send(PackageType type) { if (this._state == ProtocolState.closed) { return; } _transporter.send(PackageProtocol.encode(type)); }
public void send(PackageType type) { if (this.state == ProtocolState.closed) { return; } transporter.send(PackageProtocol.encode(type)); }
internal void send(PackageType type, byte[] body) { if (this.state != ProtocolState.closed) { byte[] buffer = PackageProtocol.encode(type, body); this.transporter.send(buffer); } }
internal void send(PackageType type) { if (this.state == ProtocolState.closed) { return; } Trace.TraceInformation("send " + type); transporter.send(PackageProtocol.encode(type)); }
// Send message use the transporter public void Send(PackageType type, byte[] body) { if (this.state == ProtocolState.closed) { return; } byte[] pkg = PackageProtocol.Encode(type, body); this.transporter.Send(pkg); }
//Send message use the transporter internal void send(PackageType type, byte[] body) { if (this.state == ProtocolState.closed) { return; } byte[] pkg = PackageProtocol.encode(type, body); transporter.send(pkg); }
internal void processMessage(byte[] bytes) { Package package = PackageProtocol.decode(bytes); if (package.type == PackageType.PKG_HANDSHAKE && this.state == ProtocolState.handshaking) { this.processHandshakeData((JsonObject)SimpleJson.SimpleJson.DeserializeObject(Encoding.UTF8.GetString(package.body))); this.state = ProtocolState.working; } else if (package.type == PackageType.PKG_HEARTBEAT && this.state == ProtocolState.working) this.heartBeatService.resetTimeout(); else if (package.type == PackageType.PKG_DATA && this.state == ProtocolState.working) { this.heartBeatService.resetTimeout(); this.pc.processMessage(this.messageProtocol.decode(package.body)); } else { if (package.type != PackageType.PKG_KICK) return; this.getPomeloClient().disconnect(); this.close(); } }
internal void send(PackageType type, byte[] body) { if (this.state == ProtocolState.closed) return; this.transporter.send(PackageProtocol.encode(type, body)); }