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 WriteInt(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         CFramework.ByteBuffer obj = (CFramework.ByteBuffer)ToLua.CheckObject <CFramework.ByteBuffer>(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         obj.WriteInt(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }