protected void _evt_Connected(bool blConnected, Beetle.ChannelEventArgs e) { string _IpPorts = string.Format("{0}:{1}", e.Channel.Socket.LocalEndPoint.ToString(), e.Channel.EndPoint.Port.ToString()); if (blConnected) { if (!dict_Channel_Connect.ContainsKey(_IpPorts)) { dict_Channel_Connect.Add(_IpPorts, e.Channel); } } else { if (dict_Channel_Connect.ContainsKey(_IpPorts)) { dict_Channel_Connect.Remove(_IpPorts); } } if (hasEvent) { OnConnect(blConnected, _IpPorts); //e.Channel.Socket.LocalEndPoint.ToString()); } }
private void OnDisposed(object sender, Beetle.ChannelEventArgs e) { Invoke(new Action <Beetle.ChannelEventArgs>(s => { txtStatus.Text = "disconnect!"; }), e); }
// 连接事件,不触发? protected override void OnConnected(object sender, Beetle.ChannelEventArgs e) { base.OnConnected(sender, e); //m_channel = e.Channel; _Connected = m_channel.Socket.Connected && !m_channel.IsDisposed; //if (hasEvent) OnConnectd(_Connected, e); }
protected override void OnConnected(object sender, Beetle.ChannelEventArgs e) { base.OnConnected(sender, e); m_channel = e.Channel; if (hasEvent) { OnConnect(true, e); } }
// 事件: 数据流接收 参数: 接收的数据 void _evt_DataReceived(byte[] buf, string sVal, Beetle.ChannelEventArgs e) { this.Invoke(new Action <string>(s => { _doRefreshUI_rcv(sVal); }), sVal ); }
// 事件: 连接 参数:连接状态 void _evt_Connected(bool blConnected, Beetle.ChannelEventArgs e) { this.Invoke(new Action <object>(o => { _doRefreshUI_cn(blConnected); }), new object() ); }
protected void _evt_DataReceived(byte[] vBuf, string vStr, Beetle.ChannelEventArgs e) { if (hasEvent) { OnDataReceived(vBuf, vStr, string.Format("{0}:{1}", e.Channel.Socket.LocalEndPoint.ToString(), e.Channel.EndPoint.Port.ToString())); } //this.Invoke(new Action<string>(s => // { // _do_DataReceive(e.Data.Array, _value); // }), // _value // ); Rcv_Data = vStr; }
protected override void OnConnected(object sender, Beetle.ChannelEventArgs e) { base.OnConnected(sender, e); Console.WriteLine("{0} connected", e.Channel.EndPoint); }