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); }
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); }
public void Start() { Client = new ClientConnect(true); Client.SetOnReceiveEvent((c, m) => { LemonMessage msg = (LemonMessage)m; if (msg.StateCode == 0) { Battle battle = (Battle) new JsonSerialize().DeserializeFromString(msg.Body, typeof(Battle)); //ReceiveCommandObj.PostAsyncMethod(battle.Step.ToString(), battle); } }); Client.OnErrorEvent = (c, e) => { }; Client.OnConnectEvent = (c) => { }; Client.Connect <LemonMessage>(IP, Port); }