void client_OnMessageReceived(StompServerClient client, StompMessage message) { if (_actionMap.ContainsKey(message.Command)) { try { if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " sent a command " + message.Command); } _actionMap[message.Command].DynamicInvoke(client, message); } catch (Exception ex) { if (StompLogger.CanLogException) { StompLogger.LogException(client.ToString() + " sent a command " + message.Command + " which caused an exception", ex); } } } else { if (StompLogger.CanLogWarning) { StompLogger.LogWarning(client.ToString() + " sent an unhandled command " + message.Command); } } }
private void OnStompCommand_Subscribe(StompServerClient client, StompMessage message) { StompPath path = null; String destination = message["destination"]; if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " subscribes to " + destination); } lock (this) { if (_paths.ContainsKey(destination)) { path = _paths[destination]; } else { path = new StompPath(destination); path.OnLastClientRemoved += new StompPath.OnLastClientRemovedDelegate(path_OnLastClientRemoved); _paths[destination] = path; } } path.AddClient(client); }
void _listener_OnConnect(StompServerClient client) { lock (this) { if (_clients.Count + 1 > StompConfiguration.MaxClients) { if (StompLogger.CanLogWarning) { StompLogger.LogWarning("Maximum clients (" + StompConfiguration.MaxClients + ") reached. Disconnecting " + client.ToString()); } client.Stop(); return; } _clients.Add(client); } InitClientsEvents(client); StompStatistics.AddConnectedClient(); client.Start(); if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " connected"); } }
void client_OnDisconnect(StompServerClient client) { lock (this) { if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " quitted"); _clients.Remove(client); } StompStatistics.RemoveConnectedClient(); }
void client_OnDisconnect(StompServerClient client) { lock (this) { if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " quitted"); } _clients.Remove(client); } StompStatistics.RemoveConnectedClient(); }
private void OnStompCommand_Connect(StompServerClient client, StompMessage message) { if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " connected with session-id " + client.SessionId.ToString()); } StompMessage result = new StompMessage("CONNECTED"); result["session-id"] = client.SessionId.ToString(); client.Send(result); }
private void OnStompCommand_Send(StompServerClient client, StompMessage message) { StompPath path = null; String destination = message["destination"]; if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " sent data to " + destination); } lock (this) { if (_paths.ContainsKey(destination)) { path = _paths[destination]; } } if (path != null) { List <StompServerClient> pathClients = path.Clients; message["message-id"] = Guid.NewGuid().ToString(); message.Command = "MESSAGE"; foreach (StompServerClient pathClient in pathClients) { try { if (StompLogger.CanLogDebug) { StompLogger.LogDebug("Sending " + message.Command + " to " + pathClient.ToString()); } pathClient.Send(message); } catch (Exception ex) { if (StompLogger.CanLogException) { StompLogger.LogException(pathClient.ToString() + " has thrown an exception while sending data", ex); } } } } }
private void OnStompCommand_Unsubscribe(StompServerClient client, StompMessage message) { StompPath path = null; String destination = message["destination"]; if (StompLogger.CanLogDebug) { StompLogger.LogDebug(client.ToString() + " unsubscribes from " + destination); } lock (this) { if (_paths.ContainsKey(destination)) { path = _paths[destination]; } } if (path != null) { path.RemoveClient(client); } }
void client_OnMessageReceived(StompServerClient client, StompMessage message) { if (_actionMap.ContainsKey(message.Command)) { try { if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " sent a command " + message.Command); _actionMap[message.Command].DynamicInvoke(client, message); } catch (Exception ex) { if (StompLogger.CanLogException) StompLogger.LogException(client.ToString() + " sent a command " + message.Command + " which caused an exception", ex); } } else { if (StompLogger.CanLogWarning) StompLogger.LogWarning(client.ToString() + " sent an unhandled command " + message.Command); } }
void _listener_OnConnect(StompServerClient client) { lock (this) { if (_clients.Count + 1 > StompConfiguration.MaxClients) { if (StompLogger.CanLogWarning) StompLogger.LogWarning("Maximum clients ("+StompConfiguration.MaxClients+") reached. Disconnecting " + client.ToString()); client.Stop(); return; } _clients.Add(client); } InitClientsEvents(client); StompStatistics.AddConnectedClient(); client.Start(); if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " connected"); }
private void OnStompCommand_Unsubscribe(StompServerClient client, StompMessage message) { StompPath path = null; String destination = message["destination"]; if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " unsubscribes from " + destination); lock (this) { if (_paths.ContainsKey(destination)) path = _paths[destination]; } if (path != null) path.RemoveClient(client); }
private void OnStompCommand_Subscribe(StompServerClient client, StompMessage message) { StompPath path = null; String destination = message["destination"]; if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " subscribes to " + destination); lock (this) { if (_paths.ContainsKey(destination)) path = _paths[destination]; else { path = new StompPath(destination); path.OnLastClientRemoved += new StompPath.OnLastClientRemovedDelegate(path_OnLastClientRemoved); _paths[destination] = path; } } path.AddClient(client); }
private void OnStompCommand_Send(StompServerClient client, StompMessage message) { StompPath path = null; String destination = message["destination"]; if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " sent data to " + destination); lock (this) { if (_paths.ContainsKey(destination)) path = _paths[destination]; } if (path != null) { List<StompServerClient> pathClients = path.Clients; message["message-id"] = Guid.NewGuid().ToString(); message.Command = "MESSAGE"; foreach (StompServerClient pathClient in pathClients) { try { if (StompLogger.CanLogDebug) StompLogger.LogDebug("Sending " + message.Command + " to " + pathClient.ToString()); pathClient.Send(message); } catch (Exception ex) { if (StompLogger.CanLogException) StompLogger.LogException(pathClient.ToString() + " has thrown an exception while sending data", ex); } } } }
private void OnStompCommand_Connect(StompServerClient client, StompMessage message) { if (StompLogger.CanLogDebug) StompLogger.LogDebug(client.ToString() + " connected with session-id " + client.SessionId.ToString()); StompMessage result = new StompMessage("CONNECTED"); result["session-id"] = client.SessionId.ToString(); client.Send(result); }