Exemplo n.º 1
0
 private void InitClient()
 {
     Client = new ClientConnect(true);
     Client.SetOnReceiveEvent((c, m) =>
     {
         LemonMessage msg = (LemonMessage)m;
         if (msg.StateCode == 0)
         {
             lock (ClientLock)
             {
                 //Debug.Log("receive:" + msg.Body);
                 Battle battle = (Battle)SerializeObject.DeserializeFromString(msg.Body, typeof(Battle));
                 ReceiveCommandObj.PostAsyncMethod(battle.Step.ToString(), battle);
             }
         }
     });
     Client.OnErrorEvent = (c, e) =>
     {
         //Debug.Log("出错了" + e.Message);
     };
     Client.OnConnectEvent = (c) =>
     {
         //Debug.Log("连接上了");
     };
     Client.OnDisconnectEvent = (c) =>
     {
         //Debug.Log("连接断开了");
     };
     Client.Connect <LemonMessage>(IP, Port);
 }
Exemplo n.º 2
0
 public void InitClient()
 {
     Client = new ClientConnect(true);
     Client.SetOnReceiveEvent((c, m) =>
     {
         LemonMessage msg = (LemonMessage)m;
         if (msg.StateCode == 0)
         {
             lock (ClientLock)
             {
                 PokerBattle battle = (PokerBattle)SerializeObject.DeserializeFromString(msg.Body, typeof(PokerBattle));
                 //Debug.Log("接收到命令" + battle.Step);
                 MsgList.Enqueue(battle);
             }
         }
     });
     Client.OnErrorEvent = (c, e) =>
     {
         //Debug.Log("出错了" + e.Message);
     };
     Client.OnConnectEvent = (c) =>
     {
         //Debug.Log("连接上了");
     };
     Client.OnDisconnectEvent = (c) =>
     {
         //Debug.Log("连接断开了");
     };
     Client.Connect <LemonMessage>(IP, Port);
 }
Exemplo n.º 3
0
        private void SendToClient(BattleCommand command, string askAccountID = null)
        {
            Battle.Step           = command;
            Battle.LibraryCardNum = CardLibrary.Count;
            string battleStr = JsonSerialize.SerializeToString(Battle);
            Battle newBattle = (Battle)JsonSerialize.DeserializeFromString(battleStr, typeof(Battle));

            Record.Add(newBattle);
            Countdown.SetCommand(command);
            ToCleintCommand.SendToClient(command, Battle, askAccountID);
        }