Exemplo n.º 1
0
 public SocketClientWithAck(ConnectArgs args, SocketCommandArgs socketArgs)
 {
     _args    = args;
     _clients = new List <IConnection <Context <byte[]>, byte[]> >();
     _connectionEnumerator = this.GetNext().GetEnumerator();
     _payload = GetChars(socketArgs.Size);
     _monitor = new ConnectionRateMonitor();
 }
Exemplo n.º 2
0
 public SocketClientWithAck(ConnectArgs args, SocketCommandArgs socketArgs)
 {
     _args = args;
     _socketArgs = socketArgs;
     _endpoint = SocketUtility.GetFirstIpEndPoint(_args.Server, _args.Port);
     _clients = new List<IConnection<Context<byte[]>, byte[]>>();
     _connections = GetNext().GetEnumerator();
     _payload = GetChars(_socketArgs.Size);
     _monitor = new ConnectionRateMonitor();
 }
Exemplo n.º 3
0
        protected virtual void OnClientConnected(Guid clientId, ClientConnection connection, string remoteAddress)
        {
            EventHandler <ConnectArgs> clientConnected = ClientConnected;

            if (clientConnected != null)
            {
                var args = new ConnectArgs(clientId, connection, remoteAddress);
                clientConnected(this, args);
            }
        }
Exemplo n.º 4
0
        private void QueueConnect(MongoServerInstance serverInstance)
        {
            var args = new ConnectArgs
            {
                ServerInstance = serverInstance,
                ResponseQueue  = _responseQueue
            };

            ThreadPool.QueueUserWorkItem(ConnectWorkItem, args);
            _connects.Add(args);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Connects to a game based on Player.IO as the given user.
        /// </summary>
        /// <param name="gameId">The ID of the game you wish to connect to. This value can be found in the admin panel.</param>
        /// <param name="connectionId">The ID of the connection, as given in the settings section of the admin panel. 'public' should be used as the default.</param>
        /// <param name="userId">The ID of the user you wish to authenticate.</param>
        /// <param name="auth">If the connection identified by ConnectionIdentifier only accepts authenticated requests: The auth value generated based on 'userId'.
        /// You can generate an auth value using the CalcAuth() method.</param>
        /// <returns>A new instance of Client if logging in was successful.</returns>
        public static Client Connect(string gameId, string connectionId, string userId, string auth)
        {
            var connectArg = new ConnectArgs
            {
                GameId       = gameId,
                ConnectionId = connectionId,
                UserId       = userId,
                Auth         = auth
            };
            var connectOutput = Channel.Request <ConnectArgs, ConnectOutput, PlayerIOError>(10, connectArg);

            return(new Client(Channel, connectOutput.Token, connectOutput.UserId));
        }
Exemplo n.º 6
0
    public static byte Convert_ConnArgs_To_Byte(ConnectArgs args)
    {
        switch (args)
        {
        case ConnectArgs.DirectConnectRequest: return(MESSAGE_TYPE__ConnectRequest);

        case ConnectArgs.JoinRoomRequest: return(MESSAGE_TYPE__ConnectRequest_NamedRoom);

        case ConnectArgs.CreateRoomRequest: return(MESSAGE_TYPE__CreateRoomRequest);

        default: return(MESSAGE_TYPE__ConnectRequest);
        }
    }
        private void QueueConnect(
            MongoServerAddress address
            )
        {
            var serverInstance = new MongoServerInstance(server, address);

            server.AddInstance(serverInstance);

            var args = new ConnectArgs {
                ServerInstance = serverInstance,
                ResponseQueue  = responseQueue
            };

            ThreadPool.QueueUserWorkItem(ConnectWorkItem, args);
            connects.Add(args);
        }
Exemplo n.º 8
0
        protected void SocketServerClientConnecting(object sender, ConnectArgs e)
        {
            Logger.InfoFormat("Client {0} connecting from {1}", e.ClientId, e.RemoteAddress);

            e.Connection.ServerAuthority
                = ServerAuthorityFactory.CreateServerAuthority();

            ServerConnectionResponse.Builder newResponse = ServerConnectionResponse.CreateBuilder();
            ServerConnectionResponse.Types.KeyParameters.Builder keyBuilder = ServerConnectionResponse.Types.KeyParameters.CreateBuilder();

            keyBuilder.SetP(e.Connection.ServerAuthority.P.ToString(16));
            keyBuilder.SetG(e.Connection.ServerAuthority.G.ToString(16));

            newResponse.SetParameters(keyBuilder.Build());
            newResponse.SetMessageId(23);
            e.Connection.Send(newResponse.Build());
        }
 public RabbitMQManagement(ConnectArgs args)
 {
     this.ConnectArgs = args;
     Connect();
 }
Exemplo n.º 10
0
        protected void SocketServerClientConnecting(object sender, ConnectArgs e)
        {
            Logger.InfoFormat("Client {0} connecting from {1}", e.ClientId, e.RemoteAddress);

            e.Connection.ServerAuthority
                = ServerAuthorityFactory.CreateServerAuthority();

            ServerConnectionResponse.Builder newResponse = ServerConnectionResponse.CreateBuilder();
            ServerConnectionResponse.Types.KeyParameters.Builder keyBuilder = ServerConnectionResponse.Types.KeyParameters.CreateBuilder();

            keyBuilder.SetP(e.Connection.ServerAuthority.P.ToString(16));
            keyBuilder.SetG(e.Connection.ServerAuthority.G.ToString(16));

            newResponse.SetParameters(keyBuilder.Build());
            newResponse.SetMessageId(23);
            e.Connection.Send(newResponse.Build());
        }
Exemplo n.º 11
0
 public RawSocketClientManager(ConnectArgs arguments, SocketCommandArgs args)
 {
     this.arguments = arguments;
     _socketCommandArgs = args;
 }
Exemplo n.º 12
0
 public SocketClientManager(ConnectArgs arguments, SocketCommandArgs args)
 {
     _arguments = arguments;
     _socketCommandArgs = args;
 }
Exemplo n.º 13
0
 private void YTClient_OnConnectEvent(object sender, ConnectArgs e)
 {
     Log(LogLevel.Info, "Connected to GoogleAPI!");
 }
        private void QueueConnect(
            MongoServerAddress address
        ) {
            var serverInstance = new MongoServerInstance(server, address);
            server.AddInstance(serverInstance);

            var args = new ConnectArgs {
                ServerInstance = serverInstance,
                ResponseQueue = responseQueue
            };
            ThreadPool.QueueUserWorkItem(ConnectWorkItem, args);
            connects.Add(args);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Connect to a ExpressVPN location.
        /// </summary>
        /// <param name="args">Connection arguments</param>
        /// <param name="timeout">Timeout waiting for the connection to be established</param>
        public async Task Connect(ConnectArgs args, int timeout = 10000)
        {
            AssertHelperConnected();

            if (LatestStatus.state != State.connected)
            {
                // A SelectLocation call is required for the browser extension
                // to show the correct location
                var selected = new SelectedLocation()
                {
                    id                = args.id,
                    name              = string.IsNullOrEmpty(args.country) ? args.name : args.country,
                    is_country        = !string.IsNullOrEmpty(args.country),
                    is_smart_location = args.is_default
                };

                if (LatestStatus.selected_location.name != selected.name)
                {
                    var    source  = new TaskCompletionSource <bool>();
                    Action handler = () => source.SetResult(true);
                    StatusUpdate += handler;

                    Call("XVPN.SelectLocation", new SelectArgs()
                    {
                        selected_location = new SelectedLocation()
                        {
                            id                = args.id,
                            name              = string.IsNullOrEmpty(args.country) ? args.name : args.country,
                            is_country        = !string.IsNullOrEmpty(args.country),
                            is_smart_location = args.is_default
                        }
                    });

                    try {
                        await WithTimeout(source.Task);
                    } finally {
                        StatusUpdate -= handler;
                    }
                }
            }

            Call("XVPN.Connect", args);

            float?progress = null;

            Action <float> progressHandler = (p) => progress = p;

            ConnectionProgress += progressHandler;

            var lastStateWasConnected = (LatestStatus.state == State.connected);
            var start = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            while (
                (
                    LatestStatus.state == State.ready ||
                    LatestStatus.state == State.connecting ||
                    LatestStatus.state == State.disconnecting ||
                    (lastStateWasConnected && LatestStatus.state == State.connected)
                ) &&
                (DateTimeOffset.Now.ToUnixTimeMilliseconds() - start) < timeout
                )
            {
                await Task.Delay(20);

                if (progress != null)
                {
                    Log.LogInformation($"Connecting... {progress:0.##}%");
                    progress = null;
                }
                if (lastStateWasConnected &&
                    (LatestStatus.state != State.connected && LatestStatus.state != State.disconnecting)
                    )
                {
                    lastStateWasConnected = false;
                }
            }
            ConnectionProgress -= progressHandler;

            if (LatestStatus.state == State.connected)
            {
                Log.LogInformation($"Finished connection with state: {LatestStatus.state}");
            }
            else if (LatestStatus.state == State.ready || LatestStatus.state == State.connecting)
            {
                throw new TimeoutException($"Timed out waiting to connect.");
            }
            else
            {
                throw new Exception($"Error while connecting, ended up in state '{LatestStatus.state}'");
            }
        }
Exemplo n.º 16
0
 public SocketClientManager(ConnectArgs arguments, SocketCommandArgs args)
 {
     _arguments         = arguments;
     _socketCommandArgs = args;
 }
Exemplo n.º 17
0
 public RawSocketClientManager(ConnectArgs arguments, SocketCommandArgs args)
 {
     this.arguments     = arguments;
     _socketCommandArgs = args;
 }
 private void QueueConnect(MongoServerInstance serverInstance)
 {
     var args = new ConnectArgs
     {
         ServerInstance = serverInstance,
         ResponseQueue = _responseQueue
     };
     ThreadPool.QueueUserWorkItem(ConnectWorkItem, args);
     _connects.Add(args);
 }
Exemplo n.º 19
0
 protected virtual void OnClientConnected(Guid clientId, ClientConnection connection, string remoteAddress)
 {
     EventHandler<ConnectArgs> clientConnected = ClientConnected;
     if (clientConnected != null)
     {
         var args = new ConnectArgs(clientId, connection, remoteAddress);
         clientConnected(this, args);
     }
 }