private void sdDiscoveryHandler(STCNeighborhood hood, STCSession session, STCNeighborhoodUpdateType type) { Debug.Write(session.Guid.ToString()); switch (type) { case STCNeighborhoodUpdateType.ARRIVAL: Debug.Write(":Session Arrived\n"); UserList.Add(session); break; //case STCNeighborhoodUpdateType.DEPARTURE: // Debug.Write(":Session Departed\n"); // UserList.Remove(session); // break; case STCNeighborhoodUpdateType.UPDATE: Debug.Write(":Session Update\n"); ///probably not the best way to do this. //UserList.Remove(session); //UserList.Add(session); break; default: Debug.Write("should not happen"); break; } ListUpdated(); }
private void tryConnect(STCSession session) { for (int i = 0; i < 5; i++) { Stopwatch sw = Stopwatch.StartNew(); addMessage(">>Connecting to " + session.User.Name); connected = false; Initiator.Start(session); while (!connected && sw.ElapsedMilliseconds < 5000) { Thread.Sleep(100); } if (connected) { break; } addMessage(">>Connection to " + session.User.Name + " timed out. Retrying."); Initiator.Stop(); } if (!connected) { addMessage(">>Connection to " + session.User.Name + " failed miserably."); } }
private void SC_InviteReceived(STCSession session, uint inviteHandle) { DialogResult result = MessageBox.Show("Accept invitation from " + session.User.Name + "?", "Invitation request", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Responder.RespondToInvite(inviteHandle, true); } else { Responder.RespondToInvite(inviteHandle, false); } }
/// <summary> /// if the invite is accepted, this event will be fired /// </summary> /// if the stream is null, the connection is dropped /// <param name="session">remote session</param> /// <param name="stream">Stream handle used for communication</param> private void SC_CommunicationStarted(STCSession session, NetStream stream) { if (stream == null) { stopChat(); //MessageBox.Show("Connection Dropped"); } else { this.Stream = stream; this.RemoteSession = session; startChat(); } }
private void sdDiscoveryHandler(STCNeighborhood hood, STCSession session, STCNeighborhoodUpdateType type) { switch (type) { case STCNeighborhoodUpdateType.ARRIVAL: UserList.Add(session); break; //case STCNeighborhoodUpdateType.DEPARTURE: // UserList.Remove(session); // break; default: break; } ListUpdated(); }
/// <summary> /// Event called when remote session responds to the invite. /// </summary> /// Handle cases where the event is accepted or rejected by the Remote /// session. The invite can also be timed out or ignored. /// <param name="session"> remote session</param> /// <param name="response">invitation responce by the remote session</param> private void SC_InviteResponded(STCSession session, InviteResponse response) { }
private void SC_InviteReceived(STCSession session, uint inviteHandle) { DialogResult result = MessageBox.Show("Accept invitation from " + session.User.Name + "?", "Invitation request", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) Responder.RespondToInvite(inviteHandle, true); else Responder.RespondToInvite(inviteHandle, false); }