Example #1
0
        public void Send(Packet packet, Stream outputStream)
        {
            diagnosticPushStream.DumpPacket(packet);

            switch (Status)
            {
            case ServerConnectionStatus.Initial:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                diagnosticPushStream.Write(packet.Payload, 0, packet.Length);
                Status = ServerConnectionStatus.PreLogin;
                break;

            case ServerConnectionStatus.PreLogin:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                loginStream.BaseStream          = diagnosticPushStream;
                loginStream.Write(packet.Payload, 0, packet.Length);
                break;

            case ServerConnectionStatus.PreGame:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                diagnosticPushStream.Write(packet.Payload, 0, packet.Length);
                Status = ServerConnectionStatus.Game;
                break;

            case ServerConnectionStatus.Game:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                sendNewGameStream.BaseStream    = diagnosticPushStream;
                sendNewGameStream.Write(packet.Payload, 0, packet.Length);
                break;
            }

            diagnosticPushStream.Finish();
        }
        public void Send(Packet packet, Stream outputStream)
        {
            diagnosticPushStream.DumpPacket(packet);

            switch (Status)
            {
                case UltimaClientConnectionStatus.Initial:
                case UltimaClientConnectionStatus.AfterInitialSeed:
                case UltimaClientConnectionStatus.ServerLogin:
                case UltimaClientConnectionStatus.PreGameLogin:
                    diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                    diagnosticPushStream.Write(packet.Payload, 0, packet.Length);
                    break;
                case UltimaClientConnectionStatus.Game:
                    diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                    sendNewGameStream.BaseStream = diagnosticPushStream;
                    var huffmanStream = new HuffmanStream(new PushStreamToStreamAdapter(sendNewGameStream));
                    huffmanStream.Write(packet.Payload, 0, packet.Length);

                    break;
                default:
                    throw new NotImplementedException($"Sending packets while in {Status} Status.");
            }

            diagnosticPushStream.Finish();
        }
Example #3
0
        public void Send(Packet packet, Stream outputStream)
        {
            diagnosticPushStream.DumpPacket(packet);

            switch (Status)
            {
            case ServerConnectionStatus.Initial:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                // TODO: use seed sent by client
                diagnosticPushStream.Write(new byte[] { 0xA9, 0xFE, 0x50, 0x50 }, 0, 4);
                Status = ServerConnectionStatus.PreLogin;
                break;

            case ServerConnectionStatus.PreLogin:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                loginStream.BaseStream          = new PushStreamToStreamAdapter(diagnosticPushStream);
                loginStream.Write(packet.Payload, 0, packet.Length);
                break;

            case ServerConnectionStatus.PreGame:
                diagnosticPushStream.BaseStream = new StreamToPushStreamAdapter(outputStream);
                diagnosticPushStream.Write(packet.Payload, 0, packet.Length);
                Status = ServerConnectionStatus.Game;
                break;

            case ServerConnectionStatus.Game:
                diagnosticPushStream.BaseStream  = new StreamToPushStreamAdapter(outputStream);
                sendNewGameStream.BasePushStream = new PushStreamToStreamAdapter(diagnosticPushStream);
                sendNewGameStream.Write(packet.Payload, 0, packet.Length);
                break;
            }

            diagnosticPushStream.Finish();
        }