internal void SendMessage(PropertyDictionary message) { try { SendTerm(Atom.From(message.PersistToString())); } catch(InvalidOperationException e) { //should we through a less generic exception to make this easier to detect? if (e.Message == "An attempt was made to send data through a closed socket.") { _parent.GracefullyHandleLostServer(); } else throw; } }
public void HandleRequest(ChatroomServerProtocol protocol, PropertyDictionary request) { if (!request.HasValueFor(ChatroomKeys.MessageType) || request.StringFor(ChatroomKeys.MessageType) != Key) { protocol.SendMalformedRequestResponse(); return; } object connected = null; lock (_lockObject) { connected = protocol.Parent.RequestLogin(protocol, request); request.SetValueFor(ChatroomKeys.Message, connected); } if (connected.ToString() == ChatroomKeys.LoginSuccess) { protocol.Parent.BroadcastServerMessage("{0} has joined.", protocol.Username); protocol.SendWelcomeMessage(); } protocol.SendTerm(Atom.From(request.PersistToString())); }
internal void SendMessage(PropertyDictionary message) { SendTerm(Atom.From(message.PersistToString())); }