Ejemplo n.º 1
0
        private void RecivePacket(object peer)
        {
            NetIncomingMessage msg;

            while ((msg = InnerClient.ReadMessage()) != null)
            {
                switch (msg.MessageType)
                {
                case NetIncomingMessageType.DebugMessage:
                case NetIncomingMessageType.ErrorMessage:
                case NetIncomingMessageType.WarningMessage:
                case NetIncomingMessageType.VerboseDebugMessage:
                    break;

                case NetIncomingMessageType.DiscoveryResponse:
                    InnerClient.Connect(msg.SenderEndPoint);
                    break;

                case NetIncomingMessageType.StatusChanged:
                    OnStatusMessage(this, msg);
                    break;

                case NetIncomingMessageType.Data:
                    OnDataMessage(this, msg);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 public void Connect(String ip, int port)
 {
     if (InnerClient.Status != NetPeerStatus.Running)
     {
         InnerClient.Start();
         NetOutgoingMessage hail = InnerClient.CreateMessage("This is the hail message");
         InnerClient.Connect(ip, port, hail);
     }
 }