コード例 #1
0
ファイル: Game.cs プロジェクト: cvanherk/3d-engine
        public Game()
        {
            InitializeComponent();


            try
            {
                Connection = new Connection(this);
                Connection.buffer = new byte[5000];
                Connection.socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
                Connection.socket.Connect("169.254.60.131",1337);
                Connection.socket.BeginReceive(Connection.buffer, 0, Connection.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), Connection);

                IsRunning = true;
                new Thread(GameThread).Start();


               
                var packetBuilder = new PacketBuilder(PacketId.Login);
                packetBuilder.WriteString("corne");
                packetBuilder.WriteString("password");

                Connection.SendPacket(packetBuilder.ToPacket());
            }
            catch (SocketException socketEx)
            {
                IsRunning = false;
                Console.WriteLine(socketEx.Message);
            }

        }
コード例 #2
0
ファイル: LoginHandler.cs プロジェクト: cvanherk/3d-engine
        public void HandlePacket(Connection connection, Packet packet)
        {
            var playerData = new PacketBuilder(packet);

            var name = playerData.ReadString();
            var password = playerData.ReadString();


            

            var player = new Player(connection);

            //player aanmaken
            //player inladen

            //-- versturen --
            //player positie
            //player rotation
            //map init
            //name

            var packetBuilder = new PacketBuilder(PacketId.Login);

            connection.SendPacket(packetBuilder.ToPacket());
        }
コード例 #3
0
ファイル: PositionHandler.cs プロジェクト: cvanherk/3d-engine
        public void HandlePacket(Connection connection, Packet packet)
        {
            var packetBuilderGet = new PacketBuilder(packet);

            Console.WriteLine("packet postion : " + packetBuilderGet.ReadInt32());

            var p = new Packet(PacketId.Position);
            var packetBuilder = new PacketBuilder(p);

            packetBuilder.WriteInt32(12);

            p = packetBuilder.ToPacket();

            connection.SendPacket(p);
        }