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


C# ITransport.ToString方法代码示例

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


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

示例1: DequeuFromTransport

 public void DequeuFromTransport(ITransport transport, DateTime currentTime)
 {
     try
     {
         var envelopes = transport.ReplayDelayed(currentTime);
         envelopes.Each(x => _logger.InfoMessage(() => new DelayedEnvelopeAddedBackToQueue {Envelope = x}));
     }
     catch (Exception e)
     {
         _logger.Error("Error while trying to dequeue delayed messages from " + transport.ToString(), e);
     }
 }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:12,代码来源:DelayedEnvelopeProcessor.cs

示例2: Add

        internal void Add(ITransport transport, TransportCallback connectCallback)
        {
            try {
                // XXX: This should be negotiated as part of the initial handshake.
                transport.Encryptor = new AESTransportEncryptor();

                transports.Add (transport);

                if (NewTransportAdded != null)
                    NewTransportAdded (transport);

                LoggingService.LogInfo(String.Format ("Transport {0} added", transport.ToString()));

                if (transport.Incoming == true) {
                    if (connectCallback != null)
                        throw new ArgumentException ("You can only specify a ConnectCallback for outoging connections!");

                    if (transport.Encryptor != null) {
                        DiffieHellmanManaged dh = new DiffieHellmanManaged ();

                        byte[] keyxBytes = new byte[transport.Encryptor.KeyExchangeLength];
                        transport.Receive (keyxBytes, 0, keyxBytes.Length);
                        keyxBytes = dh.DecryptKeyExchange (keyxBytes);

                        byte[] keyBytes = new byte[transport.Encryptor.KeySize];
                        byte[] ivBytes = new byte[transport.Encryptor.IvSize];
                        Array.Copy (keyxBytes, 0, keyBytes, 0, keyBytes.Length);
                        Array.Copy (keyxBytes, keyBytes.Length, ivBytes, 0, ivBytes.Length);

                        keyxBytes = dh.CreateKeyExchange ();
                        transport.Send (keyxBytes, 0, keyxBytes.Length);

                        transport.Encryptor.SetKey(keyBytes, ivBytes);
                    }

                    //Receive connection type, which is a ulong (8 bytes)
                    byte[] responseBuffer = new byte[8];
                        transport.Receive (responseBuffer, 0, 8);
                    ulong connectionType = EndianBitConverter.ToUInt64 (responseBuffer, 0);

                    // Recieve network ID (64 bytes)
                    responseBuffer = new byte[64];
                    transport.Receive (responseBuffer, 0, 64);
                    string networkId = EndianBitConverter.ToString (responseBuffer).Replace ("-", "");

                    // Match to one of our known networks!
                    foreach (Network network in Core.Networks) {
                        if (network.NetworkID == networkId) {
                            transport.Network = network;
                        }
                    }

                    if (transport.Network == null) {
                        throw new Exception (String.Format ("Unknown network: {0}.", networkId));
                    }

                    transport.ConnectionType = connectionType;

                    if (connectionType == ConnectionType.NodeConnection) {
                        LocalNodeConnection connection = new LocalNodeConnection(transport);
                        transport.Operation = connection;
                        transport.Network.AddConnection(connection);
                        connection.Start();
                    } else if (connectionType == ConnectionType.TransferConnection) {

                        Core.FileTransferManager.NewIncomingConnection(transport);

                    } else {
                        throw new Exception(String.Format("Unknown connection type: {0}.",
                                                          connectionType.ToString()));
                    }

                } else {
                    if (connectCallback == null) {
                        throw new ArgumentNullException("connectCallback");
                    }

                    connectCallbacks.Add (transport, connectCallback);

                    LoggingService.LogInfo("Transport {0} connecting...", transport);

                    TransportCallback callback = new TransportCallback (OnConnected);
                    transport.Connect (callback);
                }
            } catch (Exception ex) {
                transport.Disconnect (ex);
                RaiseTransportError(transport, ex);
            }
        }
开发者ID:codebutler,项目名称:meshwork,代码行数:89,代码来源:TransportManager.cs

示例3: onDisconnected

 public void onDisconnected(IMQConnection connection, 
     ITransport networkTransport)
 {
     Console.WriteLine("Disconnected from: "+connection.Addr+"/"+networkTransport.ToString());
 }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:5,代码来源:BNMQSupplier.cs


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