public void HandleClientFunctionCall(SecureSocketConnectedClient client, RemoteCallRequest request) { lock (_syncLock) { RemoteCallResponse respPacket = new RemoteCallResponse(request.CallId, request.Name); if (_functionLookup.ContainsKey(request.Name)) { RemoteFunctionBind func = _functionLookup[request.Name]; if (request.Args.Select(t => t.GetType()).Where((argType, i) => !_bindableTypes.ContainsKey(argType) || !func.ValidParameter(i, _bindableTypes[argType])).Any()) { respPacket.Response = RemoteFunctionStatus.InvalidParameters; client.Send(respPacket); return; } func.Invoke(client, respPacket, request.Args); } else { respPacket.Response = RemoteFunctionStatus.DoesNotExist; } client.Send(respPacket); } }
internal void Invoke(SecureSocketConnectedClient client, RemoteCallResponse resp, object[] param) { try { if (_authCallback?.Invoke(client, this) ?? true) { resp.Return = _functionCall.DynamicInvoke(param); resp.Response = RemoteFunctionStatus.Success; } else { resp.Response = RemoteFunctionStatus.PermissionDenied; } }catch { resp.Response = RemoteFunctionStatus.ExceptionThrown; } }
private static void OnClientDisconnect(SecureSocketConnectedClient client, Exception ex) { Global.Logger?.Execute($"Client disconnected. IP Address: {client.EndPoint}, Reason: {ex}"); }
private static void OnClientConnect(SecureSocketServer sender, SecureSocketConnectedClient client) { Global.Logger?.Execute($"New client connection, IP Address: {client.EndPoint}."); client.OnDisconnect += OnClientDisconnect; }
public void HasBeenSent(SecureSocketConnectedClient sender) { _afterSend?.Invoke(sender); }
private void Connection_OnDisconnect(SecureSocketConnectedClient client, Exception ex) { OnDisconnect?.Invoke(this, ex); }