本文整理汇总了C#中IProtocol类的典型用法代码示例。如果您正苦于以下问题:C# IProtocol类的具体用法?C# IProtocol怎么用?C# IProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProtocol类属于命名空间,在下文中一共展示了IProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenConnection
private IConnection OpenConnection(RabbitMQUri uri, IProtocol protocol)
{
int port = uri.Port.HasValue ? uri.Port.Value : protocol.DefaultPort;
ConnectionFactory connFactory = new ConnectionFactory
{
AutomaticRecoveryEnabled = true,
HostName = uri.Host,
Port = port,
Protocol = protocol
};
if (uri.Username != null)
{
connFactory.UserName = uri.Username;
}
if (uri.Password != null)
{
connFactory.Password = uri.Password;
}
if (uri.VirtualHost != null)
{
connFactory.VirtualHost = uri.VirtualHost;
}
return connFactory.CreateConnection();
}
示例2: ServerCommData
public ServerCommData(
IProtocol protocol,
ByteArrayReader incomingData = null)
: base(protocol)
{
IncomingData = incomingData;
}
示例3: SerialPortServer
public SerialPortServer(
SerialPort port,
IProtocol protocol)
{
Port = port;
Protocol = protocol;
}
示例4: RecieveThread
/// <summary>
/// Creates a RecieveThread to recieve messages on the specified protocol
/// </summary>
/// <param name="protocol">The protocol to recieve messages from</param>
/// <param name="server">The server to recieve for</param>
public RecieveThread(IProtocol protocol, INovaServer server)
{
protocols.Add(protocol);
this.server = server;
thread = new Thread(RecieveLoop);
log = LogManager.GetLogger(typeof(RecieveThread));
}
示例5: GetConnectionFactory
private ConnectionFactory GetConnectionFactory(IProtocol protocol, RabbitMqAddress brokerAddress)
{
ConnectionFactory factory = null;
var key = string.Format("{0}:{1}", protocol, brokerAddress);
if(!connectionFactories.TryGetValue(key, out factory))
{
factory = new ConnectionFactory();
factory.Endpoint = new AmqpTcpEndpoint(protocol, brokerAddress.Broker);
if(!string.IsNullOrEmpty(brokerAddress.VirtualHost))
factory.VirtualHost = brokerAddress.VirtualHost;
if(!string.IsNullOrEmpty(brokerAddress.Username))
factory.UserName = brokerAddress.Username;
if(!string.IsNullOrEmpty(brokerAddress.Password))
factory.Password = brokerAddress.Password;
factory = connectionFactories.GetOrAdd(key, factory);
log.Debug("Opening new Connection Factory " + brokerAddress + " using " + protocol.ApiName);
}
return factory;
}
示例6: HandleEvent
public void HandleEvent(IProtocol protocol, IEvent e)
{
EventId eid = (EventId)e.ID;
switch (eid)
{
case EventId.Disconnect:
Stop();
break;
case EventId.SendMessage:
if (!protocol.isClosed())
{
if (transport != null)
{
transport.Send(e.Data);
}
}
break;
case EventId.Media:
Console.WriteLine("media event received, id={0}", eid);
break;
case EventId.Content:
break;
case EventId.Stack:
break;
case EventId.Schedule:
break;
}
}
示例7: TcpServer
/// <summary>
/// Initializes a new instance of the <see cref="TcpServer"/> class.
/// </summary>
/// <remarks>If the port number is in range of the well-known ports [0 - 1024] the default port 80 is taken.</remarks>
/// <param name="service">The TCP Service implementation which can handle the incoming requests.</param>
/// <param name="portNumber">The port where this server should listen on incoming connections. Must be > 1023.</param>
/// <exception cref="PlatformNotSupportedException">Is thrown when the underlying operating system does not support <see cref="HttpListener"/>s.</exception>
/// <exception cref="ArgumentNullException">Is thrown when <paramref name="service"/> is a null reference.</exception>
/// <exception cref="ArgumentException">Is thrown when <paramref name="portNumber"/> is bigger than 65535.</exception>
public TcpServer(IProtocol service, int portNumber)
{
if (service == null)
{
throw new ArgumentNullException("service", "The Service endpoint must be an instance.");
}
if (portNumber > TcpServer.BiggestPossiblePortNumber)
{
throw new ArgumentException("The port number must be smaller than " + (TcpServer.BiggestPossiblePortNumber + 1) + ".", "portNumber");
}
if (portNumber < TcpServer.SmallestPossiblePortNumber)
{
_logger.WarnFormat("Using default port number {0} to listen on TCP requests.", portNumber);
this.ListeningPort = DefaultPortNumber;
}
var localAddress = IPAddress.Parse("127.0.0.1");
_tcpListener = new TcpListener(localAddress, portNumber);
_serviceEndpoint = service;
_logger.DebugFormat(CultureInfo.CurrentCulture, "TCP Listener created on port: " + portNumber);
this._signals[ExitThread] = this._stopThreadEvent;
this._signals[LookForNextConnection] = this._listenForConnection;
}
示例8: Peer
/// <summary>Initializes a new instance of the Peer class using the specified socket and protocol.</summary>
/// <param name="socket">Socket.</param>
/// <param name="protocol">Protocol.</param>
internal Peer(Socket socket, IProtocol protocol)
{
_socket = socket;
_protocol = protocol;
_socket.ConnectionStateChanged += OnSocketConnectionStateChanged;
_socket.DataReceived += OnSocketDataReceived;
}
示例9: AmqpTcpEndpoint
///<summary>Construct an AmqpTcpEndpoint with the given
///IProtocol, hostname, port number and ssl option. If the port
///number is -1, the default port number for the IProtocol
///will be used.</summary>
public AmqpTcpEndpoint(IProtocol protocol, string hostName, int portOrMinusOne, SslOption ssl)
{
m_protocol = protocol;
m_hostName = hostName;
m_port = portOrMinusOne;
m_ssl = ssl;
}
示例10: StreamConnection
internal StreamConnection(IReactor dispatcher, IProtocol protocol, TcpClient tcpClient, int bufferSize)
: base(dispatcher, protocol)
{
_tcpClient = tcpClient;
_readBuffer = new Byte[bufferSize];
_remoteEndPoint = _tcpClient.Client.RemoteEndPoint as IPEndPoint;
}
示例11: MainForm
/// <summary>
/// Конструктор класса
/// </summary>
/// <param name="app">Ссылка на платформу</param>
/// <param name="pBios">Ссылка на подсистему ввода/вывода платформы</param>
public MainForm(IApplication app, IEpromIO pBios, IProtocol protocol)
{
InitializeComponent();
textInserter = new TextInsert(InsertToText);
oldValue = new object();
newValue = new object();
oldValue = "0";
newValue = "0";
bios = new BIOS(app, pBios);
proto = protocol;
currentState = new ObjectCurrentState();
for (int i = 0; i < 11; i++)
{
DataGridViewRow r = new DataGridViewRow();
if ((i % 2) == 0) r.DefaultCellStyle.BackColor = Color.WhiteSmoke;
dataGridViewCalibrationTable.Rows.Add(r);
}
syncker = new Sync();
packetSyncMutex = new Mutex(false);
gr = new GraphicCalibration(CreateGraphics(), new Rectangle(12, 38, 422, 267));
gr.CalculateScale();
}
示例12: GetConnection
private IConnection GetConnection(IProtocol protocol, RabbitMqAddress brokerAddress, ConnectionFactory factory)
{
IConnection connection = null;
var key = string.Format("{0}:{1}", protocol, brokerAddress);
if (!connections.TryGetValue(key, out connection))
{
var newConnection = factory.CreateConnection();
connection = connections.GetOrAdd(key, newConnection);
//if someone else beat us from another thread kill the connection just created
if(newConnection.Equals(connection) == false)
{
newConnection.Dispose();
}
else
{
log.DebugFormat("Opening new Connection {0} on {1} using {2}",
connection, brokerAddress, protocol.ApiName);
}
}
return connection;
}
示例13: RedirectException
///<summary>Uses AmqpTcpEndpoint.Parse and .ParseMultiple to
///convert the strings, and then passes them to the other
///overload of the constructor.</summary>
public RedirectException(IProtocol protocol,
string host,
string knownHosts)
: this(ParseHost(protocol, host),
AmqpTcpEndpoint.ParseMultiple(protocol, knownHosts))
{
}
示例14: can_evaluate_4
public void can_evaluate_4()
{
auftrag = new Auftrag(new Systemschein( new Systemfeld( 1, 2, 3, 4, 7, 8, 9) { SID = 7 }));
protocol = auftrag.Tipps[0].evaluate(ausspielung);
Assert.That(protocol.Hits[6], Is.EqualTo(3));
Assert.That(protocol.Hits[8], Is.EqualTo(4));
}
示例15: can_evaluate_6_ZZ
public void can_evaluate_6_ZZ()
{
// ausspielung =: Superzahl == 0 !!!
auftrag = new Auftrag(new Normalschein( new Normalfeld( 1, 2, 3, 4, 5, 6)) { Losnummer = "0000000" });
protocol = auftrag.Tipps[0].evaluate(ausspielung);
Assert.That(protocol.Hits[1], Is.EqualTo(1));
}