Example #1
0
        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);
            }
        }
Example #2
0
 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;
     }
 }
Example #3
0
 private static void OnClientDisconnect(SecureSocketConnectedClient client, Exception ex)
 {
     Global.Logger?.Execute($"Client disconnected. IP Address: {client.EndPoint}, Reason: {ex}");
 }
Example #4
0
        private static void OnClientConnect(SecureSocketServer sender, SecureSocketConnectedClient client)
        {
            Global.Logger?.Execute($"New client connection, IP Address: {client.EndPoint}.");

            client.OnDisconnect += OnClientDisconnect;
        }
Example #5
0
 public void HasBeenSent(SecureSocketConnectedClient sender)
 {
     _afterSend?.Invoke(sender);
 }
Example #6
0
 private void Connection_OnDisconnect(SecureSocketConnectedClient client, Exception ex)
 {
     OnDisconnect?.Invoke(this, ex);
 }