コード例 #1
0
        public static BinaryWriter Create(CtosMessage message)
        {
            BinaryWriter writer = new BinaryWriter(new MemoryStream());

            writer.Write((byte)message);
            return(writer);
        }
コード例 #2
0
        public void Send(CtosMessage message, int value)
        {
            GameClientPacket packet = new GameClientPacket(message);

            packet.Write(value);
            Send(packet);
        }
コード例 #3
0
ファイル: YGOClient.cs プロジェクト: IceYGO/ygosharp
 public void Send(CtosMessage message)
 {
     using (BinaryWriter writer = new BinaryWriter(new MemoryStream()))
     {
         writer.Write((byte)message);
         Send(writer);
     }
 }
コード例 #4
0
 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);
        }
コード例 #7
0
ファイル: GameConnection.cs プロジェクト: Tic-Tac-Toc/windbot
 public void Send(CtosMessage message)
 {
     Send(new GameClientPacket(message));
 }
コード例 #8
0
ファイル: Player.cs プロジェクト: nagyistge/YGOCore
        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;
            }
        }
コード例 #9
0
 public GameClientPacket(CtosMessage message)
 {
     m_stream = new MemoryStream();
     m_writer = new BinaryWriter(m_stream);
     m_writer.Write((byte)message);
 }
コード例 #10
0
 public void Send(CtosMessage message)
 {
     Send(new GameClientPacket(message));
 }
コード例 #11
0
        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;
            }
        }
コード例 #12
0
ファイル: GamePacketWriter.cs プロジェクト: mycard/ygosharp
 public GamePacketWriter(CtosMessage message)
 {
     InitializeStream();
     _writer.Write((byte)message);
 }
コード例 #13
0
ファイル: CoreClient.cs プロジェクト: mycard/ygosharp
 public void Send(CtosMessage message, int value)
 {
     GamePacketWriter packet = new GamePacketWriter(message);
     packet.Write(value);
     Send(packet);
 }
コード例 #14
0
ファイル: CoreClient.cs プロジェクト: mycard/ygosharp
 public void Send(CtosMessage message)
 {
     Send(new GamePacketWriter(message));
 }
コード例 #15
0
 public GamePacketWriter(CtosMessage message)
 {
     InitializeStream();
     _writer.Write((byte)message);
 }
コード例 #16
0
ファイル: GameConnection.cs プロジェクト: Tic-Tac-Toc/windbot
 public void Send(CtosMessage message, byte value)
 {
     GameClientPacket packet = new GameClientPacket(message);
     packet.Write(value);
     Send(packet);
 }
コード例 #17
0
 public GameClientPacket(CtosMessage message)
 {
     _stream = new MemoryStream();
     _writer = new BinaryWriter(_stream);
     _writer.Write((byte)message);
 }
コード例 #18
0
 public static BinaryWriter Create(CtosMessage message)
 {
     BinaryWriter writer = new BinaryWriter(new MemoryStream());
     writer.Write((byte)message);
     return writer;
 }