Esempio n. 1
0
        public override void SendTo()
        {
            this.Type = Message.Type.Ready;

            if (NetworkManager.Instance.BaseClient.write.Start())
            {
                NetworkManager.Instance.BaseClient.write.PacketID(Message.Type.Ready);
                ProtoBuf.ClientReady clientReadyProto = new ProtoBuf.ClientReady
                {
                    clientInfo = new List <ProtoBuf.ClientReady.ClientInfo>()
                };
                clientReadyProto.WriteToStream(NetworkManager.Instance.BaseClient.write);
                NetworkManager.Instance.BaseClient.write.Send(new SendInfo());
            }
        }
Esempio n. 2
0
        /* Callbacks */

        public void OnNetworkMessage(Message message)
        {
            if (message.type == Message.Type.RequestUserInformation)
            {
                Console.WriteLine("[User {0}] Sending user information", this.user_index);

                if (this.raknet_client.write.Start())
                {
                    this.raknet_client.write.PacketID(Message.Type.GiveUserInformation);
                    this.raknet_client.write.UInt8(228);
                    this.raknet_client.write.UInt64(this.steam_id);
                    this.raknet_client.write.UInt32(this.game_version);
                    this.raknet_client.write.String("windows");
                    this.raknet_client.write.String(this.username);
                    this.raknet_client.write.String("public");
                    this.raknet_client.write.BytesWithSize(this.steam_token);
                    this.raknet_client.write.Send(new SendInfo());
                }
            }
            else if (message.type == Message.Type.Approved)
            {
                Console.WriteLine("[User {0}] Connection approved", this.user_index);

                if (this.raknet_client.write.Start())
                {
                    this.raknet_client.write.PacketID(Message.Type.Ready);
                    ProtoBuf.ClientReady protobuf_client_ready = new ProtoBuf.ClientReady
                    {
                        clientInfo = new List <ProtoBuf.ClientReady.ClientInfo>()
                    };
                    protobuf_client_ready.WriteToStream(this.raknet_client.write);
                    this.raknet_client.write.Send(new SendInfo());
                }
                message.connection.decryptIncoming = true;
                message.connection.encryptOutgoing = true;
                message.connection.encryptionLevel = 1;

                this.connection_status = EConnectionStatus.CONNECTED;
            }
            else if (message.type == Message.Type.ConsoleCommand)
            {
                Console.WriteLine("[User {0}] ConsoleCommand: {1}", this.user_index, message.read.String());
            }
            else if (message.type == Message.Type.ConsoleMessage)
            {
                Console.WriteLine("[User {0}] ConsoleMessage: {1}", this.user_index, message.read.String());
            }
        }