protected override void OnHandshaked() { Log.Information("Connected to service."); _connectedPrev = true; ConnectedEvent?.Invoke(this, EventArgs.Empty); }
void HandleConnectedEvent() { if (ConnectedEvent != null) { ConnectedEvent.Invoke(); } }
void HandleConnectedEvent(IConnection conn) { if (ConnectedEvent != null) { ConnectedEvent.Invoke(conn); } }
/// <summary> /// Connects the session to the given multicast group (IP address). /// </summary> /// <param name="group">The multicast group to join.</param> /// <param name="port">The port to connect to.</param> /// <param name="ttl">The multicast time to live (TTL).</param> public async Task ConnectMulticastAsync(IPAddress group, int port, int ttl) { // TODO: disconnect first? Logger.Info($"Session {Id} connecting to multicast group {group}:{port}..."); try { _socketConnecting = true; _socket = await NetUtil.ConnectMulticastAsync(group, port, ttl).ConfigureAwait(false); if (null == _socket) { await ErrorAsync($"Could not connect to multicast group {group}:{port}!").ConfigureAwait(false); return; } } finally { _socketConnecting = false; } if (IsConnected) { ConnectedEvent?.Invoke(this, new ConnectedEventArgs()); } else { // TODO: error? } }
void HandleConnectEvent() { m_State = ConnectState.Connected; m_Connection.IsConnected = true; ConnectedEvent?.Invoke(); }
void HandleConnectEvent() { m_State = ConnectState.Connected; m_Connection.IsConnected = true; if (ConnectedEvent != null) { ConnectedEvent.Invoke(); } }
void HandleConnect(int connectionId, NetworkError error) { var connection = new Connection(m_SocketId, connectionId, true, error); // add connection at correct index while (m_Connections.Count <= connectionId) { m_Connections.Add(null); } m_Connections[connectionId] = connection; ConnectedEvent?.Invoke(connection); }
protected void OnConnected() { retryCount = 0; isConnecting = false; if (connection != null) { connection.MessageRespondEvent -= OnMessageRespond; connection.MessageRespondEvent += OnMessageRespond; } ConnectedEvent?.Invoke(); InvokeStatusEvent(NetworkStatus.Connected); prevHeartbeatDateTime = DateTime.Now; StopAllCoroutines(); connectCor = StartCoroutine(ConnectionDetectAsync()); heartbeatCor = StartCoroutine(HeartbeatDetectAsync()); }
public async Task ConnectAsync() { try { await _connection.StartAsync(); NotifyNewLogMessageEvent($"Connected to hub: {Endpoint}"); IsConnected = true; ConnectedEvent?.Invoke(); } catch (Exception ex) { NotifyNewLogMessageEvent($"Something went wrong while connecting to {Endpoint}: {ex.Message}"); IsConnected = false; Task.Delay(30000).Wait(); await ConnectAsync(); } }
/// <summary> /// 运行aap服务器 /// </summary> /// <param name="app"></param> public void StartApp(ConnectedEvent app) { AppServer.Start(); App = new Thread(() => { while (true) { try { var v = AppServer.GetContext(); app?.Invoke(v); } catch (Exception ex) { ThreadMsgEvent?.BeginInvoke(ex.StackTrace, null, null); } } }); App.Start(); }
public static void AcceptCallback(IAsyncResult ar) { Debug.WriteLine("AcceptCallback"); // Get the socket that handles the client request. StateObject state = (StateObject)ar.AsyncState; Socket handler = state.listenSocket; Socket newSocket = handler.EndAccept(ar); // Create the state object. state.workSocket = newSocket; // Start reading data StartReadPacket(state); // Notify a new person connected var e = new ConnectedEventArgs(); ConnectedEvent.Invoke(null, e); }
/// <summary> /// 运行图像上传服务器 /// </summary> /// <param name="img"></param> public void StartImg(ConnectedEvent img) { ImgServer.Start(); Img = new Thread(() => { while (true) { Sem2.WaitOne(); try { var v = ImgServer.GetContext(); img?.Invoke(v); } catch (Exception ex) { ThreadMsgEvent?.BeginInvoke(ex.StackTrace, null, null); } Sem2.Release(); } }); Img.Start(); }
/// <summary> /// Connects the session to the given host:port using the given socket properties. /// </summary> /// <param name="host">The host to connect to (hostname or IP address).</param> /// <param name="port">The port to connect to.</param> /// <param name="socketType">Type of the socket.</param> /// <param name="protocolType">Type of the socket protocol.</param> /// <param name="useIPv6">if set to <c>true</c> use IPv6, otherwise use IPv4.</param> public async Task ConnectAsync(string host, int port, SocketType socketType, ProtocolType protocolType, bool useIPv6) { // TODO: disconnect first? Logger.Info($"Session {Id} connecting to {host}:{port}..."); try { _socketConnecting = true; Socket socket = await NetUtil.ConnectAsync(host, port, socketType, protocolType, useIPv6).ConfigureAwait(false); if (null == socket) { await ErrorAsync($"Could not connect to {host}:{port}!").ConfigureAwait(false); return; } if (SocketType.Stream == socketType) { _sslSocket = new SSLSocketWrapper(socket); } else { _socket = socket; } } finally { _socketConnecting = false; } if (IsConnected) { ConnectedEvent?.Invoke(this, new ConnectedEventArgs()); } else { // TODO: error? } }
public void StartConnectorLoop() { IsConnected = true; ConnectedEvent?.Invoke(this, new EventArgs()); }
/// <summary> /// When tcp client is connected to the server /// </summary> protected virtual void OnConnectedEvent() { ConnectedEvent?.Invoke(this, EventArgs.Empty); }
private void OnConnected(FeedbackEventArgs e) { ConnectedEvent?.Invoke(this, e); }
///////////////// // events from debugger connection void Connection_OnConnectedEvent() { ConnectedEvent?.Invoke(); }
void HandleConnectedEvent(IConnection conn) { ConnectedEvent?.Invoke(conn); }
protected void onConnected() { ConnectedEvent?.Invoke(this, EventArgs.Empty); }
public void OnConnected() { ConnectedEvent?.Invoke(); }
void HandleConnectedEvent() { ConnectedEvent?.Invoke(); }
private void OnConnectedEvent(EventArgs e) { ConnectedEvent?.Invoke(this, e); }
private async Task Reader() { using (HttpClient client = new HttpClient { Timeout = Timeout.InfiniteTimeSpan }) { for (int i = 1; AutoReconnect && (RetryLimit == -1 || i <= RetryLimit); i++) { try { using (var response = await client.GetAsync($"https://stream.lobi.co/2/group/{GroupID}?token={AccessToken}", HttpCompletionOption.ResponseHeadersRead)) using (var reader = new System.IO.StreamReader(await response.Content.ReadAsStreamAsync())) { i = 0; //カウンタ初期化 Connected = true; //Connected!! ConnectedEvent?.Invoke(GroupID); while (!reader.EndOfStream) { token = new CancellationTokenSource(); //トークン初期化 var jobj = await _Read(reader, token.Token); //Jsonデータ読み取り var ev = jobj["event"]?.ToString(); if (ev == "chat") { ChatEvent?.Invoke(GroupID, JsonConvert.DeserializeObject <Chat>(jobj["chat"].ToString())); } else if (ev == "chat_deleted") { ChatDeletedEvent?.Invoke(GroupID, jobj["id"].ToString()); } else if (ev == "part") { PartEvent?.Invoke(GroupID, JsonConvert.DeserializeObject <UserMinimal>(jobj["user"].ToString())); } else if (ev == "archive") { ArchiveEvent?.Invoke(GroupID); } } } token = null; Connected = false; DisconnectedEvent?.Invoke(GroupID); } catch (OperationCanceledException) { token = null; Connected = false; DisconnectedEvent?.Invoke(GroupID); return; } catch (Exception ex) { if (Connected) { token = null; Connected = false; DisconnectedEvent?.Invoke(GroupID);//必要かな?? } else { token = null; Connected = false;//一応ね } FailConnectEvent?.Invoke(GroupID, ex); } await Task.Delay(RetryCoolTimeMilliseconds);//クールタイム } } }
public override void OnConnectedToMaster() { base.OnConnectedToMaster(); ConnectedEvent?.Invoke(); }
public override void OnClientConnect(NetworkConnection conn) { base.OnClientConnect(conn); Debug.Log("connected"); OnConnected.Invoke(); }
protected virtual void OnConnected(RemoteServer server) { ConnectedEvent?.Invoke(server, EventArgs.Empty); }
protected void OnWatcherCallback() { ConnectedEvent?.Invoke(this); }
protected void OnConnectedEvent(EndPoint localEndPoint, EndPoint remoteEndPoint) { ConnectedEvent?.Invoke(this, new ConnectionEventArgs(localEndPoint, remoteEndPoint)); }
protected void RaiseConnectedEvent() { EventArgs args = new EventArgs(); ConnectedEvent?.Invoke(this, args); }
private void OnConnected() { ClientState = ClientState.Connected; ConnectedEvent?.Invoke(); }