Socket发包接口修复
This commit is contained in:
		
							parent
							
								
									1a862df685
								
							
						
					
					
						commit
						46de44df96
					
				|  | @ -26,6 +26,7 @@ class MySocket extends Socket { | |||
|             State = 1; | ||||
|         }.bindenv(this)); | ||||
|         BindFunc(SOCKET_CALLBACK_TYPE.onReceive, function(PacketId, Str) { | ||||
|             // print("收到消息:" + PacketId + " " + Str); | ||||
|             //如果存在对应处理逻辑 | ||||
|             if (PackHandler.rawin(PacketId)) { | ||||
|                 //将字符画序列化json | ||||
|  | @ -57,8 +58,10 @@ class MySocket extends Socket { | |||
| 
 | ||||
|     //发包 | ||||
|     function Send(PacketId, Jso) { | ||||
|         //将json序列化字符串 | ||||
|         local Str = Json.Encode(Jso); | ||||
|         Socket_SendPacket(getroottable()._MySocket_.Client, PacketId, Str); | ||||
|         local SendObject; | ||||
|         if (typeof Jso == "table") SendObject = Json.Encode(Jso); //table转json字符串 字符串包 | ||||
|         else if (typeof Jso == "blob") SendObject = Jso; //字节流包 | ||||
|         else SendObject = ""; //空包 | ||||
|         Socket_SendPacket(getroottable()._MySocket_.Client, PacketId, SendObject); | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue