static public void SendMatch() { if (client == null || client.socket == null || client.socket.Connected == false) { return; } MATCH_REQ person = new MATCH_REQ { }; using (MemoryStream stream = new MemoryStream()) { person.WriteTo(stream); client.WritePacket((int)PROTOCOL.IdPktMatchReq, stream.ToArray(), stream.ToArray().Length); } }
public void loop() { { if (client.socket.Connected == false) { return; } if (client.PacketQueue.Count > 0) { CompletePacket data; if (client.PacketQueue.TryDequeue(out data) == true) { switch (data.Protocol) { case (int)PROTOCOL.IdPktVersionRes: { VERSION_RES res = new VERSION_RES(); res = VERSION_RES.Parser.ParseFrom(data.Data); LOGIN_REQ person = new LOGIN_REQ { Id = PROTOCOL.IdPktLoginReq, VarToken = testcid + "000000000", VarUid = testcid.ToString() }; using (MemoryStream stream = new MemoryStream()) { person.WriteTo(stream); client.WritePacket((int)PROTOCOL.IdPktLoginReq, stream.ToArray(), stream.ToArray().Length); } client.socket.Close(); } break; case (int)PROTOCOL.IdPktLoginRes: { LOGIN_RES res = new LOGIN_RES(); res = LOGIN_RES.Parser.ParseFrom(data.Data); Console.WriteLine("IdPktLoginRes " + res.VarCode.ToString()); { MATCH_REQ person = new MATCH_REQ { }; using (MemoryStream stream = new MemoryStream()) { person.WriteTo(stream); client.WritePacket((int)PROTOCOL.IdPktMatchReq, stream.ToArray(), stream.ToArray().Length); } } } break; case (int)PROTOCOL.IdPktCreateRoomRes: { CREATE_ROOM_RES res = new CREATE_ROOM_RES(); res = CREATE_ROOM_RES.Parser.ParseFrom(data.Data); Console.WriteLine("IdPktCreateRoomRes " + res.VarCode.ToString()); return; } break; case (int)PROTOCOL.IdPktNewUserInRoomNty: { NEW_USER_IN_ROOM_NTY res = new NEW_USER_IN_ROOM_NTY(); res = NEW_USER_IN_ROOM_NTY.Parser.ParseFrom(data.Data); Console.WriteLine("IdPktNewUserInRoomNty " + res.VarCode.ToString()); } break; case (int)PROTOCOL.IdPktEnterRoomRes: { //string str = "asdfasdfasdf"; //BROADCAST_ROOM_MESSAGE_REQ req = new BROADCAST_ROOM_MESSAGE_REQ //{ //}; //req.VarMessage.CopyTo(Encoding.UTF8.GetBytes(str), 0); //using (MemoryStream stream = new MemoryStream()) //{ // req.WriteTo(stream); // client.WritePacket((int)PROTOCOL.IdPktBroadcastRoomMessageReq, stream.ToArray(), stream.ToArray().Length); //} } break; } } } } }