public RespondToInitRequestMessage(Dispatcher disp, TaskHandler handler, ClientConnectionList list, ClientConnection client, InitRequestMessage msg) : base(disp, handler) { ClientConnectionList = list; ClientConnection = client; InitRequestMessage = msg; }
public RemoveClientFromUserListTask(Dispatcher disp, TaskHandler handler, ClientConnectionList list, ClientConnection client, ObservableCollection<UserLocation> locs) : base(disp, handler) { ClientConnectionList = list; ClientConnection = client; UserLocations = locs; }
public RespondToGeoPointMessageTask(Dispatcher disp, TaskHandler handler, ClientConnectionList list, ClientConnection client, ObservableCollection<UserLocation> locs, GeoPointMessage msg) : base(disp, handler) { ClientConnectionList = list; ClientConnection = client; GeoPointMessage = msg; UserLocations = locs; }
public void OnConnectionFailed(Object sender, ClientConnection.ConnectionFailedEventArgs args) { RemoveClientFromUserListTask task = new RemoveClientFromUserListTask( Dispatcher, TaskHandler.DispatcherAsync, UserList, sender as ClientConnection, UserLocations); task.RunWorkerCompleted += TaskCompleted; task.BeginExecute(); }
/// <summary> /// Constructor for MessageWriter. /// </summary> /// <param name="inner">This is the ClientConnection that this class is inside.</param> /// <param name="connection">This is the TCPConnection that the ClientConnection is connected to.</param> /// <param name="MessageFailed">A delegate representing the method to be called whenever this MessageWriter /// fails to write a message into it's underlying TCPConnection.</param> public MessageWriter(ClientConnection inner, TCPConnection connection) { this.inner = inner; this.connection = connection; }
public AddClientToUserListTask(Dispatcher disp, TaskHandler handler, ClientConnectionList list, ClientConnection client) : base(disp, handler) { ClientConnectionList = list; ClientConnection = client; }
/// <summary> /// Method listening for incoming connections. /// </summary> private void Go() { try { while (true) { try { TCPConnection con = listener.waitForConnection(); ClientConnection client = new ClientConnection(con); client.MessageFailed += MessageFailed; client.MessageReceived += MessageReceived; client.ConnectionFailed += ConnectionFailed; if (InitialConnectionSuccess != null) { InitialConnectionSuccessEventArgs args = new InitialConnectionSuccessEventArgs(); args.Client = client; InitialConnectionSuccess(this, args); } } catch (SocketException e) { if (InitialConnectionFailed != null) { InitialConnectionFailedEventArgs args = new InitialConnectionFailedEventArgs(); args.Cause = e; InitialConnectionFailed(this, args); } } catch (InvalidOperationException e) { if (InitialConnectionFailed != null) { InitialConnectionFailedEventArgs args = new InitialConnectionFailedEventArgs(); args.Cause = e; InitialConnectionFailed(this, args); } } } } catch (ThreadAbortException) { // do something ? } }
public void OnMessageReceived(Object sender, ClientConnection.MessageReceivedEventArgs args) { ClientConnection client = sender as ClientConnection; if (args.Message is InitRequestMessage) { RespondToInitRequestMessage task = new RespondToInitRequestMessage( Dispatcher, TaskHandler.DispatcherAsync, UserList, client, args.Message as InitRequestMessage); task.RunWorkerCompleted += TaskCompleted; task.BeginExecute(); } else if (args.Message is GeoPointMessage) { RespondToGeoPointMessageTask task = new RespondToGeoPointMessageTask( Dispatcher, TaskHandler.DispatcherAsync, UserList, client, UserLocations, args.Message as GeoPointMessage); task.RunWorkerCompleted += TaskCompleted; task.BeginExecute(); } else if (args.Message is MultipleGeoPointRequestMessage) { MultipleGeoPointResponseMessage msg = null; lock (UserLocations) { msg = new MultipleGeoPointResponseMessage(UserLocations.ToList()); } client.Notify(msg); } }
public void OnMessageFailed(Object sender, ClientConnection.MessageFailedEventArgs args) { }