public void SendSelectHero(uint heroid) { ReqSelectHero match = new ReqSelectHero(); match.userid = NetData.Instance.mUserData.Userid; match.heroid = heroid; match.roomid = NetData.Instance.mFightData.RoomId; using (MemoryStream stream = new MemoryStream()) { Serializer.Serialize(stream, match); Send(Protocol.ReqSelectHero, stream.ToArray()); } }
public void ReqSelectHero(ReqSelectHero selectHero) { uint userid = selectHero.userid; uint roomid = selectHero.roomid; uint heroid = selectHero.heroid; if (!CheckDataaVailability(userid, roomid)) { return; } System.Console.WriteLine("ReqSelectHero userid = {0}, roomid = {1}, heroid = {2}", userid, roomid, heroid); Room room = m_RoomDic[roomid]; room.SetHero(userid, heroid); }
internal static void MessageHandle(AsyncUserToken asyncUserToken, byte tType, byte[] tData) { using (MemoryStream stream = new MemoryStream(tData)) { Console.WriteLine("收到消息类型 = {0}", (Protocol)tType); switch ((Protocol)tType) { case Protocol.ReqLogin: ReqLogin login = Serializer.Deserialize <ReqLogin>(stream); MessageHandle(asyncUserToken, login); break; case Protocol.ReqMatch: ReqMatch match = Serializer.Deserialize <ReqMatch>(stream); MessageHandle(asyncUserToken, match); break; case Protocol.ReqSelectHero: ReqSelectHero selectHero = Serializer.Deserialize <ReqSelectHero>(stream); MessageHandle(asyncUserToken, selectHero); break; } } }
internal static void MessageHandle(AsyncUserToken asyncUserToken, ReqSelectHero selectHero) { asyncUserToken.mServer.m_RoomManager.ReqSelectHero(selectHero); }