本文整理汇总了C#中IConnection.BeginReceive方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.BeginReceive方法的具体用法?C# IConnection.BeginReceive怎么用?C# IConnection.BeginReceive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConnection
的用法示例。
在下文中一共展示了IConnection.BeginReceive方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindEvents
/// <summary>
/// Binds the events for any incoming TCP activity
/// </summary>
protected void BindEvents(IConnection underlyingConnection)
{
underlyingConnection.OnConnection += OnConnect;
underlyingConnection.OnDisconnection += OnDisconnect;
underlyingConnection.OnError += OnException;
underlyingConnection.BeginReceive(OnMessage);
}
示例2: OnConnected
public void OnConnected(IConnection connection)
{
Console.WriteLine("connected from:" + connection.RemoteEndPoint.ToString());
//开始接收数据,没有这个操作将不接受该连接发送的数据
connection.BeginReceive();
}
示例3: ConnectionEstablishedCallback
private void ConnectionEstablishedCallback(INode remoteAddress, IConnection responseChannel)
{
Invoke((Action) (() =>
{
AppendStatusText(string.Format("Connected to {0}", remoteAddress));
responseChannel.BeginReceive();
tsStatusLabel.Text = string.Format("Connected to {0}", remoteAddress);
btnConnect.Enabled = false;
btnDisconnect.Enabled = true;
btnSend.Enabled = true;
tbSend.Enabled = true;
}));
}
示例4: Listen
public override Task<Tuple<Address, TaskCompletionSource<IAssociationEventListener>>> Listen()
{
var listenAddress = NodeBuilder.BuildNode().Host(Settings.Hostname).WithPort(Settings.Port);
var publicAddress = NodeBuilder.BuildNode().Host(Settings.PublicHostname).WithPort(Settings.Port);
var newServerChannel = NewServer(listenAddress);
newServerChannel.Open();
publicAddress.Port = newServerChannel.Local.Port; //use the port assigned by the transport
//Block reads until a handler actor is registered
//TODO
ConnectionGroup.TryAdd(newServerChannel);
ServerChannel = newServerChannel;
var addr = NodeToAddress(publicAddress, SchemeIdentifier, System.Name, Settings.PublicHostname);
if(addr == null) throw new HeliosNodeException("Unknown local address type {0}", newServerChannel.Local);
LocalAddress = addr;
AssociationListenerPromise.Task.ContinueWith(result => ServerChannel.BeginReceive(), TaskContinuationOptions.ExecuteSynchronously);
return Task.Run(() => Tuple.Create(addr, AssociationListenerPromise));
}
示例5: ConnectionEstablishedCallback
private void ConnectionEstablishedCallback(INode remoteAddress, IConnection responseChannel)
{
responseChannel.BeginReceive();
//Invoke((Action)(() =>
//{
// AppendStatusText(string.Format("Connected to {0}", remoteAddress));
// responseChannel.BeginReceive();
// tsStatusLabel.Text = string.Format("Connected to {0}", remoteAddress);
// btnSend.Enabled = true;
// tbSend.Enabled = true;
//}));
}
示例6: OnConnect
protected override void OnConnect(INode remoteAddress, IConnection responseChannel)
{
//Got to pass OnMessage here or get null reference.
responseChannel.BeginReceive(OnMessage);
_handler.OnConnect(remoteAddress, responseChannel);
}
示例7: OnConnected
/// <summary>
/// OnConnected
/// </summary>
/// <param name="connection"></param>
protected override void OnConnected(IConnection connection)
{
base.OnConnected(connection);
this._currentConnection = connection;
connection.BeginReceive();
string[] channels = null;
string[] patterns = null;
lock (this)
{
if (this._setChannels.Count > 0)
{
channels = new string[this._setChannels.Count];
this._setChannels.CopyTo(channels);
}
if (this._setPatterns.Count > 0)
{
patterns = new string[this._setPatterns.Count];
this._setPatterns.CopyTo(patterns);
}
}
this.SubscribeInternal(channels);
this.PatternSubscribeInternal(patterns);
}
示例8: OnConnected
/// <summary>
/// OnConnected
/// </summary>
/// <param name="connection"></param>
protected override void OnConnected(IConnection connection)
{
autoEvent.Set();
connection.BeginReceive();//异步开始接收数据
//触发事件
try { this._handler.OnConnected(connection); }
catch (Exception ex) { Log.Trace.Error(ex.Message, ex); }
}