Esempio n. 1
0
        private void SendSessionStart(ClientStatus sendServer, ClientStatus clientStatus)
        {
            using (var memory = new MemoryStream())
            {
                using (BinaryWriter binaryStream = new BinaryWriter(memory, System.Text.Encoding.UTF8))
                {
                    binaryStream.Write(Message.IdSessionStart);
                    binaryStream.Write(clientStatus.nickName);
                }

                Send(sendServer, memory.ToArray());
            }
        }
Esempio n. 2
0
        private void SendNetworkId(ClientStatus client)
        {
            using (var memory = new MemoryStream())
            {
                using (BinaryWriter binaryStream = new BinaryWriter(memory, System.Text.Encoding.UTF8))
                {
                    binaryStream.Write(Message.IdGetNetworkId);
                    binaryStream.Write(client.networkId);


                    Console.WriteLine("return msg: ---------------");
                    Console.WriteLine("nickName:" + client.nickName);
                    Console.WriteLine("address:" + client.address);
                    Console.WriteLine("port:" + client.port);
                    Console.WriteLine("networkId:" + client.networkId);
                    Console.WriteLine("---------------------------");
                }

                Send(client, memory.ToArray());
            }
        }
Esempio n. 3
0
        public UDPClient(int setPort, int setServerPort, string name) : base(setPort)
        {
            // ホスト名を取得する
            string hostname = Dns.GetHostName();

            // ホスト名からIPアドレスを取得する
            IPAddress[] adrList = Dns.GetHostAddresses(hostname);

            surverStatus          = new ClientStatus();
            surverStatus.address  = adrList[1];
            surverStatus.port     = setServerPort;
            surverStatus.nickName = "server";


            status          = new ClientStatus();
            status.address  = adrList[1];
            status.port     = sendPort;
            status.nickName = name;

            Console.WriteLine("MyPort:" + myPort);
            Console.WriteLine("ServerPort:" + sendPort);

            SendSessionStart(surverStatus, status);
        }