public static BinaryWriter Create(CtosMessage message) { BinaryWriter writer = new BinaryWriter(new MemoryStream()); writer.Write((byte)message); return(writer); }
public void Send(CtosMessage message, int value) { GameClientPacket packet = new GameClientPacket(message); packet.Write(value); Send(packet); }
public void Send(CtosMessage message) { using (BinaryWriter writer = new BinaryWriter(new MemoryStream())) { writer.Write((byte)message); Send(writer); } }
public void Send(CtosMessage message) { using (BinaryWriter writer = new BinaryWriter(new MemoryStream())) { writer.Write((byte)message); Send(writer); } }
public CtosMessage ReadCtos() { if (ctos == byte.MaxValue) { ctos = ReadByte(); } if (CtosMessage.IsDefined(typeof(CtosMessage), ctos)) { return((CtosMessage)ctos); } return(CtosMessage.Unknown); }
public static CtosMessage Handler(GameSession player, params GameClientPacket[] packets) { CtosMessage firstmsg = CtosMessage.Unknown; if (packets == null || packets.Length == 0) { return(firstmsg); } foreach (GameClientPacket packet in packets) { // Parse(player, packet); if (packet.Length == 0) { continue; } CtosMessage msg = packet.ReadCtos(); if (firstmsg == CtosMessage.Unknown) { firstmsg = msg; } if (msg == CtosMessage.CreateGame || msg == CtosMessage.JoinGame || msg == CtosMessage.PlayerInfo) { } else { if (!player.IsAuthentified) { Logger.Warn("auth error:" + player.Name); player.CloseAsync(); break; } if (player.Type == (int)PlayerType.Undefined) { Logger.Warn("player type error:" + player.Name); player.CloseAsync(); break; } } if (player.Game != null) { lock (player.Game.AsyncRoot){ EventHandler.Do((ushort)msg, player, packet); } } else { EventHandler.Do((ushort)msg, player, packet); } packet.Close(); } return(firstmsg); }
public void Send(CtosMessage message) { Send(new GameClientPacket(message)); }
public void Parse(GameClientPacket packet) { CtosMessage msg = packet.ReadCtos(); switch (msg) { case CtosMessage.PlayerInfo: OnPlayerInfo(packet); break; case CtosMessage.JoinGame: if (Program.Config.MyCard) { onJoinMyCardStyleGame(packet); } else { OnJoinGame(packet); } break; case CtosMessage.CreateGame: OnCreateGame(packet); break; } if (!IsAuthentified) { return; } switch (msg) { case CtosMessage.Chat: OnChat(packet); break; case CtosMessage.HsToDuelist: Game.MoveToDuelist(this); break; case CtosMessage.HsToObserver: Game.MoveToObserver(this); break; case CtosMessage.LeaveGame: Game.RemovePlayer(this); break; case CtosMessage.HsReady: Game.SetReady(this, true); break; case CtosMessage.HsNotReady: Game.SetReady(this, false); break; case CtosMessage.HsKick: OnKick(packet); break; case CtosMessage.HsStart: Game.StartDuel(this); break; case CtosMessage.HandResult: OnHandResult(packet); break; case CtosMessage.TpResult: OnTpResult(packet); break; case CtosMessage.UpdateDeck: OnUpdateDeck(packet); break; case CtosMessage.Response: OnResponse(packet); break; case CtosMessage.Surrender: Game.Surrender(this, 0); break; } }
public GameClientPacket(CtosMessage message) { m_stream = new MemoryStream(); m_writer = new BinaryWriter(m_stream); m_writer.Write((byte)message); }
public void Send(CtosMessage message) { Send(new GameClientPacket(message)); }
public void Parse(BinaryReader packet) { CtosMessage msg = (CtosMessage)packet.ReadByte(); switch (msg) { case CtosMessage.PlayerInfo: OnPlayerInfo(packet); break; case CtosMessage.JoinGame: OnJoinGame(packet); break; case CtosMessage.CreateGame: OnCreateGame(packet); break; } if (!IsAuthentified) { return; } switch (msg) { case CtosMessage.Chat: OnChat(packet); break; case CtosMessage.HsToDuelist: Game.MoveToDuelist(this); break; case CtosMessage.HsToObserver: Game.MoveToObserver(this); break; case CtosMessage.LeaveGame: Game.RemovePlayer(this); break; case CtosMessage.HsReady: Game.SetReady(this, true); break; case CtosMessage.HsNotReady: Game.SetReady(this, false); break; case CtosMessage.HsKick: OnKick(packet); break; case CtosMessage.HsStart: Game.StartDuel(this); break; case CtosMessage.HandResult: OnHandResult(packet); break; case CtosMessage.TpResult: OnTpResult(packet); break; case CtosMessage.UpdateDeck: OnUpdateDeck(packet); break; case CtosMessage.Response: OnResponse(packet); break; case CtosMessage.Surrender: Game.Surrender(this, 0); break; } }
public GamePacketWriter(CtosMessage message) { InitializeStream(); _writer.Write((byte)message); }
public void Send(CtosMessage message, int value) { GamePacketWriter packet = new GamePacketWriter(message); packet.Write(value); Send(packet); }
public void Send(CtosMessage message) { Send(new GamePacketWriter(message)); }
public GamePacketWriter(CtosMessage message) { InitializeStream(); _writer.Write((byte)message); }
public void Send(CtosMessage message, byte value) { GameClientPacket packet = new GameClientPacket(message); packet.Write(value); Send(packet); }
public GameClientPacket(CtosMessage message) { _stream = new MemoryStream(); _writer = new BinaryWriter(_stream); _writer.Write((byte)message); }
public static BinaryWriter Create(CtosMessage message) { BinaryWriter writer = new BinaryWriter(new MemoryStream()); writer.Write((byte)message); return writer; }