当前位置: 首页>>代码示例>>C#>>正文


C# Connection.ToString方法代码示例

本文整理汇总了C#中System.Net.Connection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ToString方法的具体用法?C# Connection.ToString怎么用?C# Connection.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Connection的用法示例。


在下文中一共展示了Connection.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PluginMessageReceived

        private void PluginMessageReceived(PacketHeader header, Connection connection, string message)
        {
            logging.AddToLog("\nA message was recieved from " + connection.ToString() + " which said '" + message + "'.", true);

            string[] arguments = message.Split('|');
            bool local = false;
            if (arguments[1] == "True")
            {
                OSAEObjectStateManager.ObjectStateSet(arguments[0], "ON", sourceName);
            }
            else if (arguments[1] == "False")
            {
                OSAEObjectStateManager.ObjectStateSet(arguments[0], "OFF", sourceName);
            }

            foreach (Plugin p in plugins)
            {
                if (p.PluginName == arguments[0])
                {
                    local = true;

                    OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
                    if (obj != null)
                    {
                        if (arguments[1] == "True")
                        {
                            enablePlugin(p);
                            UDPConnection.SendObject("Plugin", p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Running | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10000));
                        }
                        else if (arguments[1] == "False")
                        {
                            disablePlugin(p);
                            UDPConnection.SendObject("Plugin", p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Stopped | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10000));
                        }
                    }
                }
            }
            if (!local)
            {
                UDPConnection.SendObject("Plugin", message, new IPEndPoint(IPAddress.Broadcast, 10000));
            }
        }
开发者ID:jberry,项目名称:Open-Source-Automation,代码行数:42,代码来源:OSAEService.Networking.cs

示例2: PluginMessageReceived

        private void PluginMessageReceived(PacketHeader header, Connection connection, string message)
        {
            Log.Info("A message was recieved from " + connection.ToString() + " which said '" + message + "'.");

            string[] arguments = message.Split('|');
            bool local = false;
            if (arguments[1] == "True")
                OSAEObjectStateManager.ObjectStateSet(arguments[0], "ON", "SYSTEM");
            else if (arguments[1] == "False")
                OSAEObjectStateManager.ObjectStateSet(arguments[0], "OFF", "SYSTEM");

            foreach (Plugin p in plugins)
            {
                if (p.PluginName == arguments[0])
                {
                    local = true;

                    OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
                    if (obj != null)
                    {
                        if (arguments[1] == "True")
                        {
                            // enablePlugin(p);
                            // maybe this call should be enable/disable, not sure, moving on
                            startPlugin("SYSTEM", p);
                            UDPConnection.SendObject("Plugin", p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Running | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
                        }
                        else if (arguments[1] == "False")
                        {
                            stopPlugin("SYSTEM", p);
                            UDPConnection.SendObject("Plugin", p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Stopped | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
                        }
                    }
                }
            }
            if (!local) UDPConnection.SendObject("Plugin", message, new IPEndPoint(IPAddress.Broadcast, 10051));
        }
开发者ID:opensourceautomation,项目名称:Open-Source-Automation,代码行数:37,代码来源:OSAEService.Networking.cs

示例3: MethodMessageReceived

 private void MethodMessageReceived(PacketHeader header, Connection connection, string message)
 {
     logging.AddToLog("\nA message was recieved from " + connection.ToString() + " which said '" + message + "'.", true);
 }
开发者ID:jberry,项目名称:Open-Source-Automation,代码行数:4,代码来源:OSAEService.Networking.cs

示例4: Run

        /// <summary> Acceptor thread. Continuously accept new connections. Create a new thread for each new
        /// connection and put it in conns. When the thread should stop, it is
        /// interrupted by the thread creator.
        /// </summary>
        public virtual void Run(Object arg)
        {
            Object[] objArr = arg as object[];
            TcpListener listener = objArr[0] as TcpListener;
            bool isPrimaryListener = (bool)objArr[1];

            System.Net.Sockets.Socket client_sock;
            Connection conn = null;
            Address peer_addr = null;

            while (listener != null)
            {
                try
                {
                    client_sock = listener.AcceptSocket();
                    int cport = ((IPEndPoint)client_sock.RemoteEndPoint).Port;

                     if (NCacheLog.IsInfoEnabled) NCacheLog.Info("ConnectionTable.Run()", "CONNECTION ACCPETED Remote port = " + cport);
                    client_sock.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);
                    
                    client_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, send_buf_size);
                    client_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, recv_buf_size);

                    object size = client_sock.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer);
                    size = client_sock.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer);
                    // create new thread and add to conn table

                    conn = new Connection(this, client_sock, null, _ncacheLog, true, nagglingSize, _retries, _retryInterval); // will call receive(msg)

                    // get peer's address
                    bool connectingFirstTime = conn.readPeerAddress(client_sock, ref peer_addr);
                    conn.sendLocalAddress(local_addr,connectingFirstTime);
                    ConnectInfo conInfo = null;
                    if (((Address)local_addr).CompareTo((Address)peer_addr) > 0)
                    {
                        conInfo = new ConnectInfo(ConnectInfo.CONNECT_FIRST_TIME, GetConnectionId());
                        if (NCacheLog.IsInfoEnabled) NCacheLog.Info("ConnectionTable.Run", peer_addr + " I should send connect_info");

                       
                        conn.SendConnectInfo(conInfo);
                    }
                    else
                    {
                        conInfo = conn.ReadConnectInfo(client_sock);
                        
                    }

                    conn.ConInfo = conInfo;
                    conn.ConInfo.ConnectStatus = connectingFirstTime ? ConnectInfo.CONNECT_FIRST_TIME : ConnectInfo.RECONNECTING;

                    if (NCacheLog.IsInfoEnabled) NCacheLog.Info("ConnectionTable.Run()", "Read peer address " + peer_addr.ToString() + "at port" + cport);

                    conn.PeerAddress = peer_addr;

                    if (conInfo.ConnectStatus == ConnectInfo.RECONNECTING)
                    {
                        //if other node is reconnecting then we should check for its member ship first.
                        bool ismember = enclosingInstance.IsMember(peer_addr);
                        if (!ismember)
                        {

                            NCacheLog.CriticalInfo("ConnectionTa ble.Run", "ConnectionTable.Run" + peer_addr + " has connected. but it is no more part of the membership");

                            conn.SendLeaveNotification();
                            Thread.Sleep(1000); //just to make sure that peer node receives the leave notification.
                            conn.Destroy();
                            continue;
                        }
                    }

                    bool isPrimary = true;

                    if (NCacheLog.IsInfoEnabled) NCacheLog.Info("ConnectionTable.run", "b4 lock conns.SyncRoot");
                    try
                    {
                        conn_syn_lock.AcquireWriterLock(Timeout.Infinite);

                        if (isPrimaryListener)
                        {

                           if (conns_NIC_1.ContainsKey(peer_addr))
                            {

                                if (!secondayrConns_NIC_1.Contains(peer_addr) && useDualConnection)
                                {
                                    secondayrConns_NIC_1[peer_addr] = conn;
                                    isPrimary = false;
                                }
                                else
                                {

                                
                                    Connection tmpConn = (Connection)conns_NIC_1[peer_addr];

                                    if (conn.ConInfo.Id < tmpConn.ConInfo.Id && conn.ConInfo.ConnectStatus != ConnectInfo.CONNECT_FIRST_TIME)

//.........这里部分代码省略.........
开发者ID:javithalion,项目名称:NCache,代码行数:101,代码来源:ConnectionTable.cs

示例5: MethodMessageReceived

 private void MethodMessageReceived(PacketHeader header, Connection connection, string message)
 {
     Log.Info("A message was recieved from " + connection.ToString() + " which said '" + message + "'.");
 }
开发者ID:opensourceautomation,项目名称:Open-Source-Automation,代码行数:4,代码来源:OSAEService.Networking.cs


注:本文中的System.Net.Connection.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。