private RegistryResponse CallRegisteredFunction(JSMarshallContainer marshallContainer) { // Check registry for functions that have return values. if (_registry.ContainsKey(marshallContainer.MethodName)) { return(WrapException(() => { var result = _registry[marshallContainer.MethodName](marshallContainer); return new RegistryResponse(result); })); } // Check registry for void functions. if (_registryVoid.ContainsKey(marshallContainer.MethodName)) { return(WrapException(() => { _registryVoid[marshallContainer.MethodName](marshallContainer); return new RegistryResponse(null, RegistryErrorType.None); })); } // Spit out an error if unhandled. return(new RegistryResponse(null, RegistryErrorType.UnknownValue)); }
private void ChatEntered(JSMarshallContainer container) { var data = new ChatEntered(container); _chatManager.SendChatToServer(data.Chat); ClearChatInput(); }
protected void ChangeZoom(JSMarshallContainer container) { var data = container as ChangeZoom; if (data.ZoomDirection == ZoomDirection.In) { Camera.Zoom += data.Amount; } else { Camera.Zoom -= data.Amount; } }
protected void ChangeZoom(JSMarshallContainer container) { var data = container as ChangeZoom; if (data.ZoomDirection == ZoomDirection.In) { Camera.Zoom += data.Amount; } else { Camera.Zoom -= data.Amount; } MathHelper.Clamp(Camera.Zoom, 0.1f, 1f); }
private async Task <RegistryResponse> CallRegisteredFunctionAsync(JSMarshallContainer marshallContainer) { // Spit out error if unhandled. if (!_registry.ContainsKey(marshallContainer.MethodName)) { return(new RegistryResponse(null, RegistryErrorType.UnknownValue)); } // Async call function and return response. try { var result = await _registryAsync[marshallContainer.MethodName](marshallContainer); return(new RegistryResponse(result)); } catch (Exception e) { // Toss error in message response and hand it back. return(new RegistryResponse(e)); } }
protected void SendStructurePlacementRequest(JSMarshallContainer request) { var req = request as StructurePlacementRequest;//Hmmm...would be nice to come up with a way to avoid this. _messageService.SendStructurePlacementRequest(req.StructureType, new Vector2(req.PosX, req.PosY), _playerShipManager.PlayerShip.Id); }
private void FetchChats(JSMarshallContainer container) { ClearChatInput(); SetChatHistory(_chatManager.GetChatsJson()); }
public ChatEntered(JSMarshallContainer container) { Chat = container.Arguments.FirstOrDefault().ToString(); }