/// <summary> /// defines the execution of the command. /// </summary> /// <param name="args"> arguments for the command</param> /// <param name="clientInfo"> info of client the sent the command</param> public override void Execute(string[] args, ClientConnectionInfo clientInfo) { string name; int rows, cols; try { name = args[0]; rows = int.Parse(args[1]); cols = int.Parse(args[2]); } catch { JObject errorMessage = new JObject(); errorMessage["Error"] = "missing arguments"; controller.View.SendReply(errorMessage.ToString(), clientInfo); return; } if (controller.MultiplePlayerMazes.ContainsKey(name)) { JObject errorMessage = new JObject(); errorMessage["Error"] = "game already started"; controller.View.SendReply(errorMessage.ToString(), clientInfo); return; } Maze maze = controller.Model.GenerateMaze(name, rows, cols); controller.MultiplePlayerMazes.Add(name, maze); controller.CreatedGamesPlayers.Add(name, clientInfo); }
/// <summary> /// Gets the connection. /// </summary> /// <param name="userId">The user id.</param> /// <param name="clientType">Type of the client.</param> /// <param name="deviceId">The device id.</param> /// <param name="deviceName">Name of the device.</param> /// <returns>ClientConnectionInfo.</returns> private ClientConnectionInfo GetConnection(Guid userId, string clientType, string deviceId, string deviceName) { lock (_activeConnections) { var conn = _activeConnections.FirstOrDefault(c => string.Equals(c.Client, clientType, StringComparison.OrdinalIgnoreCase) && string.Equals(deviceId, c.DeviceId)); if (conn == null) { conn = new ClientConnectionInfo { UserId = userId, Client = clientType, DeviceName = deviceName, DeviceId = deviceId }; _activeConnections.Add(conn); } else { conn.UserId = userId; } return(conn); } }
/// <summary> /// defines the execution of the command. /// </summary> /// <param name="args"> arguments for the command</param> /// <param name="clientInfo"> info of client the sent the command</param> public override void Execute(string[] args, ClientConnectionInfo clientInfo) { string name; try { name = args[0]; } catch // in case there is overflow in the index in the array { JObject errorMessage = new JObject(); errorMessage["Error"] = "missing arguments"; controller.View.SendReply(errorMessage.ToString(), clientInfo); return; } if (!controller.MultiplePlayerMazes.ContainsKey(name)) { JObject errorMessage = new JObject(); errorMessage["Error"] = String.Format("game {0} doesn't exist", name); controller.View.SendReply(errorMessage.ToString(), clientInfo); return; } ClientConnectionInfo startedGameClient = controller.CreatedGamesPlayers[name]; MazeGame mazeGame = new MazeGame(controller.MultiplePlayerMazes[name], startedGameClient, clientInfo, controller.View, controller.Model); controller.CreatedGamesPlayers.Remove(name); controller.PlayersGamesBelonging[startedGameClient] = mazeGame; controller.PlayersGamesBelonging[clientInfo] = mazeGame; }
private ExecutingQuery Query(ClientConnectionInfo sessionInfo, string username, string queryText, IDictionary <string, object> @params, IDictionary <string, object> metaData) { Thread thread = Thread.CurrentThread; return(new ExecutingQuery(_queryId++, sessionInfo.WithUsername(username), username, queryText, ValueUtils.asMapValue(@params), metaData, () => 0, new PageCursorCountersAnonymousInnerClass(this) , thread.Id, thread.Name, _clock, CpuClock, HeapAllocation)); }
/// <summary> /// Starts the client for a match in online mode /// </summary> /// <param name="msgTypeToMsgHandler">Message handlers provided from the game</param> private void StartOnlineClient(Dictionary <Type, IMessageHandlerCommandClient> msgTypeToMsgHandler) { messageHandler = new MatchMessageHandler(logger, EventHandler, msgTypeToMsgHandler); var connectioninfo = new ClientConnectionInfo(persistentData.port, persistentData.ip); client = new Client(this, connectioninfo, messageHandler, persistentData, logger, this, config); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private QueryStatusResult(org.neo4j.kernel.api.query.QuerySnapshot query, org.neo4j.kernel.impl.core.EmbeddedProxySPI manager, java.time.ZoneId zoneId) throws org.neo4j.kernel.api.exceptions.InvalidArgumentsException private QueryStatusResult(QuerySnapshot query, EmbeddedProxySPI manager, ZoneId zoneId) { this.QueryId = ofInternalId(query.InternalQueryId()).ToString(); this.Username = query.Username(); this.Query = query.QueryText(); this.Parameters = AsRawMap(query.QueryParameters(), new ParameterWriter(manager)); this.StartTime = formatTime(query.StartTimestampMillis(), zoneId); this.ElapsedTimeMillis = MicrosAsMillis(query.ElapsedTimeMicros()).Value; this.ElapsedTime = formatInterval(ElapsedTimeMillis); ClientConnectionInfo clientConnection = query.ClientConnection(); this.ConnectionDetails = clientConnection.AsConnectionDetails(); this.Protocol = clientConnection.Protocol(); this.ClientAddress = clientConnection.ClientAddress(); this.RequestUri = clientConnection.RequestURI(); this.MetaData = query.TransactionAnnotationData(); this.CpuTimeMillis = MicrosAsMillis(query.CpuTimeMicros()); this.Status = query.Status(); this.ResourceInformation = query.ResourceInformation(); this.ActiveLockCount = query.ActiveLockCount(); this.WaitTimeMillis = MicrosAsMillis(query.WaitTimeMicros()).Value; this.IdleTimeMillis = MicrosAsMillis(query.IdleTimeMicros()); this.Planner = query.Planner(); this.Runtime = query.Runtime(); this.Indexes = query.Indexes(); this.AllocatedBytes = query.AllocatedBytes(); this.PageHits = query.PageHits(); this.PageFaults = query.PageFaults(); this.ConnectionId = clientConnection.ConnectionId(); }
/// <summary> /// in charge of sending the clients message about a movement in the game. /// </summary> /// <param name="move">the move</param> /// <param name="clientInfo">the client info who moved</param> public void NotifyOfMove(string move, ClientConnectionInfo clientInfo) { Array directions = Enum.GetValues(typeof(Direction)); int i; for (i = 0; i < directions.Length; i++) { if (directions.GetValue(i).ToString().Equals(move)) { break; } } if (i == 4) // there was not found appropriate value in the Direction enum { JObject errorMessage = new JObject(); errorMessage["Error"] = "invalid direction key word"; view.SendReply(errorMessage.ToString(), clientInfo); return; } JObject movement = new JObject(); movement["Name"] = maze.Name; movement["Direction"] = move; if (clientInfo.Equals(Player1)) { view.SendReply(movement.ToString(), Player2); } else { view.SendReply(movement.ToString(), Player1); } }
public ExecutingQuery(long queryId, ClientConnectionInfo clientConnection, string username, string queryText, MapValue queryParameters, IDictionary <string, object> transactionAnnotationData, System.Func <long> activeLockCount, PageCursorCounters pageCursorCounters, long threadExecutingTheQueryId, string threadExecutingTheQueryName, SystemNanoClock clock, CpuClock cpuClock, HeapAllocation heapAllocation) { if (!InstanceFieldsInitialized) { InitializeInstanceFields(); InstanceFieldsInitialized = true; } // Capture timestamps first this._cpuTimeNanosWhenQueryStarted = cpuClock.CpuTimeNanos(threadExecutingTheQueryId); this._startTimeNanos = clock.Nanos(); this._startTimestampMillis = clock.Millis(); // then continue with assigning fields this._queryId = queryId; this._clientConnection = clientConnection; this._pageCursorCounters = pageCursorCounters; this._username = username; ISet <string> passwordParams = new HashSet <string>(); this._queryText = QueryObfuscation.ObfuscateText(queryText, passwordParams); this._queryParameters = QueryObfuscation.ObfuscateParams(queryParameters, passwordParams); this._transactionAnnotationData = transactionAnnotationData; this._activeLockCount = activeLockCount; this._initialActiveLocks = activeLockCount(); this._threadExecutingTheQueryId = threadExecutingTheQueryId; this._threadExecutingTheQueryName = threadExecutingTheQueryName; this._cpuClock = cpuClock; this._heapAllocation = heapAllocation; this._clock = clock; this._heapAllocatedBytesWhenQueryStarted = heapAllocation.AllocatedBytes(this._threadExecutingTheQueryId); }
public override Neo4jTransactionalContext NewContext(ClientConnectionInfo clientConnection, InternalTransaction tx, string queryText, MapValue queryParameters) { Statement initialStatement = _statementSupplier.get(); ClientConnectionInfo connectionWithUserName = clientConnection.WithUsername(tx.SecurityContext().subject().username()); ExecutingQuery executingQuery = initialStatement.QueryRegistration().startQueryExecution(connectionWithUserName, queryText, queryParameters); return(_contextCreator.create(tx, initialStatement, executingQuery)); }
public virtual TransactionalContext Create(HttpServletRequest request, GraphDatabaseQueryService service, Transaction_Type type, LoginContext loginContext, string query, IDictionary <string, object> queryParameters) { TransactionalContextFactory contextFactory = Neo4jTransactionalContextFactory.create(service, _locker); ClientConnectionInfo clientConnection = HttpConnectionInfoFactory.create(request); InternalTransaction transaction = service.BeginTransaction(type, loginContext); return(contextFactory.NewContext(clientConnection, transaction, query, ValueUtils.asMapValue(queryParameters))); }
public void SendHandshakeResponse(ClientConnectionInfo connection, HandshakeResponseCode responseCode) { var handShakeResponse = new HandshakeResponse { ResponseCode = responseCode }; DefaultSend(connection, handShakeResponse.Create(), ChannelID.Handshaking, true); }
/// <summary> /// Starts the client for matchmaking in online mode /// </summary> private void StartOnlineClient(string inputName) { persistentData.PlayerInfo = new Shared_PlayerInfo() { username = "******" }; messageHandler = new MMMessageHandler(this, updateController, logger, persistentData); client = new Client(this, ClientConnectionInfo.MatchMakerConnectionInfo(clientConfig), messageHandler, persistentData, logger, this, clientConfig); }
public ClientConnection(ClientConnectionInfo connectionInfo, ILogger logger, IConnectionResultHandler handler) { this.handler = handler; this.logger = logger; string host = connectionInfo.Ip; int port = connectionInfo.Port; logger.Log("Connecting created"); ConnectToServer(host, port); }
public void SendLoginResponse(ClientConnectionInfo connection, LoginResponseCode responseCode, string sceneName) { var loginResponse = new LoginResponse { ResponseCode = responseCode, SceneName = sceneName, }; DefaultSend(connection, loginResponse.Create(), ChannelID.Handshaking, true); }
/// <summary> /// the constructor. /// </summary> /// <param name="maze">the game</param> /// <param name="player1">the first player</param> /// <param name="player2">the second player</param> /// <param name="view">the view</param> /// <param name="model">the model</param> public MazeGame(Maze maze, ClientConnectionInfo player1, ClientConnectionInfo player2, IView view, IModel model) { this.maze = maze; this.Player1 = player1; this.Player2 = player2; this.view = view; this.model = model; SendGameStartedMessage(); }
public Client(IUnityComponentResetable owner, ClientConnectionInfo connectionInfo, IMessageHandler messageHandler, PersistentData data, ILogger logger, IConnectionResultHandler connectionResultHandler, IClientConfig config) { this.owner = owner; this.logger = logger; connection = new ClientConnection(connectionInfo, logger, connectionResultHandler); sender = Client_MessageSenderFactory.CreateSender(config, config.GetClock(), connection, logger, this); this.messageHandler = messageHandler; reciever = new Client_MessageReciever(connection, messageHandler); this.data = data; this.config = config; }
//inventory object of some sort public Player(ClientConnectionInfo connection, int entityId, Vector position, Vector rotation, string username, int level, int experience) { Connection = connection; Position = position; Rotation = rotation; EntityID = entityId; Username = username; Level = level; Experience = experience; }
/// <summary> /// defines the execution of the command. /// </summary> /// <param name="args"> arguments for the command</param> /// <param name="clientInfo"> info of client the sent the command</param> public override void Execute(string[] args, ClientConnectionInfo clientInfo) { JArray gamesList = new JArray(); foreach (KeyValuePair <string, ClientConnectionInfo> game in controller.CreatedGamesPlayers) { gamesList.Add(game.Key); } controller.View.SendReply(gamesList.ToString(), clientInfo); clientInfo.ShouldKeepConnection = false; }
public override void Handle(byte[] data, ClientConnectionInfo connection) { var loginRequest = new LoginRequest(data); //TODO: IMPLEMENT ACCOUNT SYSTEM AND PLAYER DATA var loginEvent = new LoginEvent(LoginEventType.LoginRequest) { Connection = connection, Username = loginRequest.Username, PasswordHash = loginRequest.PasswordHash }; _gameServer.EventBus.PublishEvent(loginEvent); }
/// <summary> /// Gets an object that represents the current client /// connected to the application in the current request. /// </summary> public ClientConnectionInfo GetConnectionInfo() { var context = _httpContextAccessor.HttpContext; var info = new ClientConnectionInfo(); if (context != null && context.Request != null) { info.IPAddress = context?.Connection?.RemoteIpAddress?.ToString(); info.UserAgent = context.Request?.Headers?.GetOrDefault("User-Agent"); } return(info); }
public override void Handle(byte[] data, ClientConnectionInfo connection) { var encryptionRequest = new EncryptionRequest(data); if (encryptionRequest.PublicRSAKey.Length < 32) { _gameServer.PacketSenderManager.SendEncryptionResponse(connection, EncryptionResponseCode.INVALID_KEY, new byte[] { 0 }, new byte[] { 0 }); return; } connection.Encryption.EnableRSAEncryption(encryptionRequest.PublicRSAKey); _gameServer.PacketSenderManager.SendEncryptionResponse(connection, EncryptionResponseCode.OK, _gameServer.EncryptionManager.GetKeyAES(), _gameServer.EncryptionManager.GetIVAes()); connection.Encryption.DisableRSAEncryption(); connection.Encryption.AESEncryptionEnabled = true; }
/// <summary> /// in charge of sending the clients messages about the finish of the game. /// </summary> /// <param name="client">the reuqesting to close game client info</param> public void NotifyGameFinish(ClientConnectionInfo client) { JObject finishGame = new JObject(); if (client.Equals(Player1)) { view.SendReply(finishGame.ToString(), Player2); } else { view.SendReply(finishGame.ToString(), Player1); } Player1.ShouldKeepConnection = false; Player2.ShouldKeepConnection = false; }
/// <summary> /// Добавление сессии и соединения к указанному пользователю /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="connectionInfo">The connection information.</param> public OperationResult AddShellToPool(string userId, ClientConnectionInfo connectionInfo) { if (!_shellPoolDictionary.TryGetValue(userId, out var sessionsModel)) { sessionsModel = new UserSessions(userId, _hubContext); var connectResult = sessionsModel.TryAddSessionUserAndConnect(connectionInfo); if (connectResult.Success) { _shellPoolDictionary.TryAdd(userId, sessionsModel); } return(connectResult); } return(sessionsModel.TryAddSessionUserAndConnect(connectionInfo)); }
/// <summary> /// defines the execution of the command. /// </summary> /// <param name="args"> arguments for the command</param> /// <param name="clientInfo"> info of client the sent the command</param> public override void Execute(string[] args, ClientConnectionInfo clientInfo) { string move; try { move = args[0]; } catch { JObject errorMessage = new JObject(); errorMessage["Error"] = "missing arguments"; controller.View.SendReply(errorMessage.ToString(), clientInfo); return; } controller.PlayersGamesBelonging[clientInfo].NotifyOfMove(move, clientInfo); }
public void UpdateClientConnectionInfo(ClientConnectionInfo msg) { var obj = new ConnectionClientData(); obj.ClientAddress = AddressFun(msg); obj.Ping = msg.Ping; obj.PingDeviation = msg.PingDeviation; obj.ConnectedTime = msg.ConnectedTime; obj.PacketsSentSpeech = msg.PacketsSentSpeech; obj.PacketsSentKeepalive = msg.PacketsSentKeepalive; obj.PacketsSentControl = msg.PacketsSentControl; obj.BytesSentSpeech = msg.BytesSentSpeech; obj.BytesSentKeepalive = msg.BytesSentKeepalive; obj.BytesSentControl = msg.BytesSentControl; obj.PacketsReceivedSpeech = msg.PacketsReceivedSpeech; obj.PacketsReceivedKeepalive = msg.PacketsReceivedKeepalive; obj.PacketsReceivedControl = msg.PacketsReceivedControl; obj.BytesReceivedSpeech = msg.BytesReceivedSpeech; obj.BytesReceivedKeepalive = msg.BytesReceivedKeepalive; obj.BytesReceivedControl = msg.BytesReceivedControl; obj.ServerToClientPacketlossSpeech = msg.ServerToClientPacketlossSpeech; obj.ServerToClientPacketlossKeepalive = msg.ServerToClientPacketlossKeepalive; obj.ServerToClientPacketlossControl = msg.ServerToClientPacketlossControl; obj.ServerToClientPacketlossTotal = msg.ServerToClientPacketlossTotal; obj.ClientToServerPacketlossSpeech = msg.ClientToServerPacketlossSpeech; obj.ClientToServerPacketlossKeepalive = msg.ClientToServerPacketlossKeepalive; obj.ClientToServerPacketlossControl = msg.ClientToServerPacketlossControl; obj.ClientToServerPacketlossTotal = msg.ClientToServerPacketlossTotal; obj.BandwidthSentLastSecondSpeech = msg.BandwidthSentLastSecondSpeech; obj.BandwidthSentLastSecondKeepalive = msg.BandwidthSentLastSecondKeepalive; obj.BandwidthSentLastSecondControl = msg.BandwidthSentLastSecondControl; obj.BandwidthSentLastMinuteSpeech = msg.BandwidthSentLastMinuteSpeech; obj.BandwidthSentLastMinuteKeepalive = msg.BandwidthSentLastMinuteKeepalive; obj.BandwidthSentLastMinuteControl = msg.BandwidthSentLastMinuteControl; obj.BandwidthReceivedLastSecondSpeech = msg.BandwidthReceivedLastSecondSpeech; obj.BandwidthReceivedLastSecondKeepalive = msg.BandwidthReceivedLastSecondKeepalive; obj.BandwidthReceivedLastSecondControl = msg.BandwidthReceivedLastSecondControl; obj.BandwidthReceivedLastMinuteSpeech = msg.BandwidthReceivedLastMinuteSpeech; obj.BandwidthReceivedLastMinuteKeepalive = msg.BandwidthReceivedLastMinuteKeepalive; obj.BandwidthReceivedLastMinuteControl = msg.BandwidthReceivedLastMinuteControl; obj.FiletransferBandwidthSent = msg.FiletransferBandwidthSent; obj.FiletransferBandwidthReceived = msg.FiletransferBandwidthReceived; obj.IdleTime = msg.IdleTime; SetConnectionClientData(obj, msg.ClientId); }
public void SendEncryptionResponse(ClientConnectionInfo connection, EncryptionResponseCode responseCode, byte[] key, byte[] iv) { var handShakeResponse = new EncryptionResponse { ResponseCode = responseCode, AESKey = key, IV = iv }; if (responseCode == EncryptionResponseCode.OK) { RSAEncryptedSend(connection, handShakeResponse.Create(), ChannelID.Handshaking, true); } else { DefaultSend(connection, handShakeResponse.Create(), ChannelID.Handshaking, true); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public TransactionStatusResult(org.neo4j.kernel.api.KernelTransactionHandle transaction, TransactionDependenciesResolver transactionDependenciesResolver, java.util.Map<org.neo4j.kernel.api.KernelTransactionHandle,java.util.List<org.neo4j.kernel.api.query.QuerySnapshot>> handleSnapshotsMap, java.time.ZoneId zoneId) throws org.neo4j.kernel.api.exceptions.InvalidArgumentsException public TransactionStatusResult(KernelTransactionHandle transaction, TransactionDependenciesResolver transactionDependenciesResolver, IDictionary <KernelTransactionHandle, IList <QuerySnapshot> > handleSnapshotsMap, ZoneId zoneId) { this.TransactionId = transaction.UserTransactionName; this.Username = transaction.Subject().username(); this.StartTime = ProceduresTimeFormatHelper.FormatTime(transaction.StartTime(), zoneId); Optional <Status> terminationReason = transaction.TerminationReason(); this.ActiveLockCount = transaction.ActiveLocks().count(); IList <QuerySnapshot> querySnapshots = handleSnapshotsMap[transaction]; TransactionExecutionStatistic statistic = transaction.TransactionStatistic(); ElapsedTimeMillis = statistic.ElapsedTimeMillis; CpuTimeMillis = statistic.CpuTimeMillis; AllocatedBytes = statistic.HeapAllocatedBytes; AllocatedDirectBytes = statistic.DirectAllocatedBytes; WaitTimeMillis = statistic.WaitTimeMillis; IdleTimeMillis = statistic.IdleTimeMillis; PageHits = statistic.PageHits; PageFaults = statistic.PageFaults; if (querySnapshots.Count > 0) { QuerySnapshot snapshot = querySnapshots[0]; ClientConnectionInfo clientConnectionInfo = snapshot.ClientConnection(); this.CurrentQueryId = ofInternalId(snapshot.InternalQueryId()).ToString(); this.CurrentQuery = snapshot.QueryText(); this.Protocol = clientConnectionInfo.Protocol(); this.ClientAddress = clientConnectionInfo.ClientAddress(); this.RequestUri = clientConnectionInfo.RequestURI(); this.ConnectionId = clientConnectionInfo.ConnectionId(); } else { this.CurrentQueryId = StringUtils.EMPTY; this.CurrentQuery = StringUtils.EMPTY; this.Protocol = StringUtils.EMPTY; this.ClientAddress = StringUtils.EMPTY; this.RequestUri = StringUtils.EMPTY; this.ConnectionId = StringUtils.EMPTY; } this.ResourceInformation = transactionDependenciesResolver.DescribeBlockingLocks(transaction); this.Status = GetStatus(transaction, terminationReason, transactionDependenciesResolver); this.MetaData = transaction.MetaData; }
/// <inheritdoc /> public Task <OperationResult> Handle(ConnectToSourceCommand request, CancellationToken cancellationToken) { try { var model = request.Model; var connectionInfo = new ClientConnectionInfo { Host = model.Host, Password = model.Password, Port = model.Port, UserName = model.UserName }; return(Task.FromResult(_shellPoll.AddShellToPool(_httpContextAccessor.HttpContext?.User.Identity?.Name ?? string.Empty, connectionInfo))); } catch (Exception ex) { throw new SshTerminalException(_localizer[SshTerminalConstants.ConnectToSourceError], ex); } }
/// <summary> /// defines the execution of the command. /// </summary> /// <param name="args"> arguments for the command</param> /// <param name="clientInfo"> info of client the sent the command</param> public override void Execute(string[] args, ClientConnectionInfo clientInfo) { string name; try { name = args[0]; } catch // in case there is overflow in the index in the array { JObject errorMessage = new JObject(); errorMessage["Error"] = "missing arguments"; controller.View.SendReply(errorMessage.ToString(), clientInfo); return; } MazeGame game = controller.PlayersGamesBelonging[clientInfo]; game.NotifyGameFinish(clientInfo); controller.MultiplePlayerMazes.Remove(name); controller.PlayersGamesBelonging.Remove(game.Player1); controller.PlayersGamesBelonging.Remove(game.Player2); }
public void HandleData(byte[] data, ClientConnectionInfo connection) { if (connection.Encryption.AESEncryptionEnabled) { data = _gameServer.EncryptionManager.DecryptDataAES(data); } if (!_handlers.ContainsKey((PacketOP)data[0])) { ConsoleUtils.Warning("Received invalid packet from client on {0} with Packet OP {1}", connection.Peer.GetRemoteAddress(), data[0]); //TODO: FIX THAT THE ENCRYPTION IS WRONG WHEN A CLIENT CONNECTS FOR THE SECOND TIME WHILE THE SERVER IS RUNNING return; } try { _handlers[(PacketOP)data[0]].Handle(data, connection); } catch (Exception e) { ConsoleUtils.Warning("An error occured while trying to read {0} packet from client at {1}", (PacketOP)data[0], connection.Peer.GetRemoteAddress()); Logger.LogError(e.GetBaseException().ToString()); } }