コード例 #1
0
        public void Shutdown(string reason = null)
        {
            if (_socket == null)
            {
                return;
            }

            Clear();

            if (reason != null)
            {
                StreamUnreliable.WriteUShort((ushort)ENetCommand.NetDisconnect);
                StreamUnreliable.WriteString(reason);
                Transmit();
            }

            _socket        = null;
            _remoteAddress = null;

            if (_messageHandler != null)
            {
                _messageHandler.ConnectionClosing(reason);
                _messageHandler = null;
            }

            _netMesages.Clear();
            Networking.RemoveChannel(this);
        }
コード例 #2
0
 public void DenyFile(string fileName, uint transferId)
 {
     StreamReliable.WriteUShort((ushort)ENetCommand.NetFile);
     StreamReliable.WriteUInt(transferId);
     StreamReliable.WriteString(fileName);
     StreamReliable.WriteByte(0);
 }
コード例 #3
0
ファイル: Networking.cs プロジェクト: Draiget/EnviumNetTest
        public static void OutOfBandPrintf(Socket socket, EndPoint addr, string format, params object[] args)
        {
            var msg = new BufferWrite();

            msg.WriteBytes(NetProtocol.ConnectionlessHeader);
            msg.WriteString(string.Format(format, args));

            SendPacket(null, socket, addr, msg.GetData());
        }
コード例 #4
0
        private void SendConnectPacket(int challengeNr, int authProtocol)
        {
            var serverEp = (EndPoint) new IPEndPoint(IPAddress.Any, 0);

            if (!Networking.StringToAddr(_retryAddress, ref serverEp))
            {
                Console.WriteLine("Bad server address ({0})!\n", serverEp);
                Disconnect();
                return;
            }

            var msg = new BufferWrite();

            msg.WriteBytes(NetProtocol.ConnectionlessHeader);
            msg.WriteChar((char)EConnectionType.PlayerConnect);
            msg.WriteInt(Program.ProtocolVersion);
            msg.WriteInt(authProtocol);
            msg.WriteInt(challengeNr);
            msg.WriteString(Program.ClientName);
            msg.WriteString(Program.ServerPassword);

            Networking.SendPacket(null, _socket, serverEp, msg.GetData());
        }
コード例 #5
0
        private void ReplyChallenge(EndPoint clientEp)
        {
            var msg = new BufferWrite();

            // get a free challenge number
            var challengeNr = GetChallengeNr(clientEp);

            msg.WriteBytes(NetProtocol.ConnectionlessHeader);

            msg.WriteChar((char)EConnectionType.ServerChallenge);
            msg.WriteInt(challengeNr);
            msg.WriteInt(1); // auth protocol
            msg.WriteString("EE00");

            Networking.SendPacket(null, Socket, clientEp, msg.GetData());
        }