Ejemplo n.º 1
0
 /// <summary>
 /// 发送数据给服务器
 /// </summary>
 public void SendCommand(int commandId, ByteBuffer data = null)
 {
     if (IsConnected == false)
     {
         return;
     }
     try
     {
         ByteBuffer buffer = new ByteBuffer();
         buffer.WriteInt(commandId);
         if (data == null)
         {
             //buffer.WriteBuffer(null);
         }
         else
         {
             buffer.WriteBytes(data.ToBytes());
         }
         _clientSocket.Send(buffer.ToBytes());
     }
     catch
     {
         IsConnected = false;
         _clientSocket.Shutdown(SocketShutdown.Both);
         _clientSocket.Close();
     }
 }
Ejemplo n.º 2
0
 static int ToBytes(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         CFramework.ByteBuffer obj = (CFramework.ByteBuffer)ToLua.CheckObject <CFramework.ByteBuffer>(L, 1);
         byte[] o = obj.ToBytes();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }