コード例 #1
0
        /// <summary>
        /// Send a message to an unconnected host
        /// </summary>
        public void SendUnconnectedMessage(NetOutgoingMessage msg, string host, int port)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (msg.m_isSent)
            {
                throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
            }
            if (msg.LengthBytes > m_configuration.MaximumTransmissionUnit)
            {
                throw new NetException("Unconnected messages too long! Must be shorter than NetConfiguration.MaximumTransmissionUnit (currently " + m_configuration.MaximumTransmissionUnit + ")");
            }

            IPAddress adr = NetUtility.Resolve(host);

            if (adr == null)
            {
                throw new NetException("Failed to resolve " + host);
            }

            msg.m_messageType = NetMessageType.Unconnected;

            Interlocked.Increment(ref msg.m_recyclingCount);
            m_unsentUnconnectedMessages.Enqueue(new NetTuple <IPEndPoint, NetOutgoingMessage>(new IPEndPoint(adr, port), msg));
        }
コード例 #2
0
        /// <summary>
        /// Emit a discovery signal to a single known host
        /// </summary>
        public bool DiscoverKnownPeer(string host, int serverPort)
        {
            IPAddress address = NetUtility.Resolve(host);

            if (address == null)
            {
                return(false);
            }
            DiscoverKnownPeer(new IPEndPoint(address, serverPort));
            return(true);
        }
コード例 #3
0
ファイル: NetPeer.cs プロジェクト: aastorg2/ContractsSubjects
 /// <summary>
 /// Create a connection to a remote endpoint
 /// </summary>
 public NetConnection Connect(string host, int port, NetOutgoingMessage hailMessage)
 {
     return(Connect(new IPEndPoint(NetUtility.Resolve(host), port), hailMessage));
 }
コード例 #4
0
ファイル: NetPeer.cs プロジェクト: aastorg2/ContractsSubjects
 /// <summary>
 /// Create a connection to a remote endpoint
 /// </summary>
 public NetConnection Connect(string host, int port)
 {
     return(Connect(new IPEndPoint(NetUtility.Resolve(host), port), null));
 }