GetString() публичный Метод

public GetString ( int maxLength ) : string
maxLength int
Результат string
Пример #1
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Server] ReceiveUnconnected {0}. From: {1}. Data: {2}", messageType, remoteEndPoint, reader.GetString(100));
     NetDataWriter wrtier = new NetDataWriter();
     wrtier.Put("SERVER DISCOVERY RESPONSE :)");
     Server.SendDiscoveryResponse(wrtier, remoteEndPoint);
 }
Пример #2
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Client] ReceiveUnconnected {0}. From: {1}. Data: {2}", messageType, remoteEndPoint, reader.GetString(100));
     if (messageType == UnconnectedMessageType.DiscoveryResponse)
     {
         Client.Connect(remoteEndPoint);
     }
 }
Пример #3
0
 public void OnNetworkReceiveUnconnected(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
 {
     Console.WriteLine("[Server] ReceiveUnconnected: {0}", reader.GetString(100));
 }
Пример #4
0
 private void HandleNatIntroductionRequest(NetEndPoint senderEndPoint, NetDataReader dr)
 {
     NetEndPoint localEp = dr.GetNetEndPoint();
     string token = dr.GetString(MaxTokenLength);
     lock (_requestEvents)
     {
         _requestEvents.Enqueue(new RequestEventData
         {
             LocalEndPoint = localEp,
             RemoteEndPoint = senderEndPoint,
             Token = token
         });
     }
 }
Пример #5
0
        private void HandleNatIntroduction(NetDataReader dr)
        {
            // read intro
            byte hostByte = dr.GetByte();
            NetEndPoint remoteInternal = dr.GetNetEndPoint();
            NetEndPoint remoteExternal = dr.GetNetEndPoint();
            string token = dr.GetString(MaxTokenLength);

            NetUtils.DebugWrite(ConsoleColor.Cyan, "[NAT] introduction received; we are designated " + (hostByte == HostByte ? "host" : "client"));
            NetDataWriter writer = new NetDataWriter();

            // send internal punch
            writer.Put(hostByte);
            writer.Put(token);
            _netBase.SendRaw(NetPacket.CreateRawPacket(PacketProperty.NatPunchMessage, writer), remoteInternal);
            NetUtils.DebugWrite(ConsoleColor.Cyan, "[NAT] internal punch sent to " + remoteInternal);

            // send external punch
            writer.Reset();
            writer.Put(hostByte);
            writer.Put(token);
            _netBase.SendRaw(NetPacket.CreateRawPacket(PacketProperty.NatPunchMessage, writer), remoteExternal);
            NetUtils.DebugWrite(ConsoleColor.Cyan, "[NAT] external punch sent to " + remoteExternal);
        }
Пример #6
0
        private void HandleNatPunch(NetEndPoint senderEndPoint, NetDataReader dr)
        {
            byte fromHostByte = dr.GetByte();
            if (fromHostByte != HostByte && fromHostByte != ClientByte)
            {
                //garbage
                return;
            }

            //Read info
            string additionalInfo = dr.GetString(MaxTokenLength);
            NetUtils.DebugWrite(ConsoleColor.Green, "[NAT] punch received from {0} - additional info: {1}", senderEndPoint, additionalInfo);

            //Release punch success to client; enabling him to Connect() to msg.Sender if token is ok
            lock (_successEvents)
            {
                _successEvents.Enqueue(new SuccessEventData { TargetEndPoint = senderEndPoint, Token = additionalInfo });
            }
        }