public CsStructure(Structure structure, PropertyDictionary options) { _structure = structure; _options = options; if (_options.HasStringFor("surrogate-for") && !_options.HasValueFor("surrogate-for-is-reference-type")) { throw new LanguageException("Any use of \"surrogate-for\" must be accompanied with \"surrogate-for-is-reference-type\"."); } }
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())); }
public void HandleRequest(ChatroomServerProtocol protocol, PropertyDictionary request) { if (!request.HasValueFor(ChatroomKeys.MessageType) || !(request.StringFor(ChatroomKeys.MessageType) == Key)) { protocol.SendMalformedRequestResponse(); return; } lock (_lockObject) { string sender = protocol.Parent.ResolveSenderName(request); if (sender != null) { request[ChatroomKeys.SenderName] = sender; protocol.Parent.Broadcast(request); } else { protocol.SendMalformedRequestResponse(); } } }
internal string ResolveSenderName(PropertyDictionary request) { if (request.HasValueFor(ChatroomKeys.SenderId)) { ChatroomServerProtocol protocol = _clients[request.StringFor(ChatroomKeys.SenderId)]; return protocol == null ? null : protocol.Username; } return null; }