private void MessageReceived(IRemoteConnection sender, string message) { messageCount++; if (message.StartsWith(MessagePrefix.MAP)) { MapMessage mapMessage = new MapMessage(); mapMessage.DeserializeArguments(message.Remove(0, MessagePrefix.MAP.Length)); MapMessages.Enqueue(mapMessage); } else if (message.StartsWith(MessagePrefix.BANK)) { BankMessage bankMessage = new BankMessage(); bankMessage.DeserializeArguments(message.Remove(0, MessagePrefix.BANK.Length)); BankMessages.Enqueue(bankMessage); } else if (message.StartsWith(MessagePrefix.CAMERA)) { Debug.Log("received " + message); CameraMessage camMessage = new CameraMessage(); camMessage.DeserializeArguments(message.Remove(0, MessagePrefix.CAMERA.Length)); CameraMessages.Enqueue(camMessage); } }
/// <summary> /// Creates a connection pool with <paramref name="size"/> connections. /// </summary> /// <param name="conn">The connection to use as the basis.</param> /// <param name="size">The number of connections.</param> /// <returns>A promise to return a pool logged-in of <paramref name="size"/> /// logged in connections</returns> public static IPromise <ConnectionPool> Create(IRemoteConnection conn, int size) { var result = new ConnectionPool(conn, size); return(result._available .Convert(a => result)); }
public void Login(ICredentials credentials) { _lastCredentials = credentials; var mapping = _mappings.First(m => m.Databases.Contains(credentials.Database)); _current = mapping.Connection; _current.Login(credentials); }
private void FireConnectionOpened(IRemoteConnection connection) { if (ConnectionOpened != null) { ConnectionOpened(connection); } }
public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) { var source = new GraphTraversalSource(TraversalStrategies, Bytecode); source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); return(source); }
public IPromise<string> Login(ICredentials credentials, bool async) { _lastCredentials = credentials; var mapping = _mappings.First(m => m.Databases.Contains(credentials.Database)); _current = mapping.Connection; return _current.Login(credentials, async); }
private static bool ConnectionRequested(IRemoteConnection sender, string request, out string response) { Player player = null; switch (request) { case "body": player = new Player(request, sender, PlayerType.BODY); PLAYERS.Add(sender, player); GlobalServer.Instance.AddPlayer(player.Id, sender); GameModel.Instance.BodyPlayer = player; GameModel.Instance.BodyCamInit = false; break; case "soul": player = new Player(request, sender, PlayerType.SOUL); PLAYERS.Add(sender, player); GlobalServer.Instance.AddPlayer(player.Id, sender); GameModel.Instance.SoulPlayer = player; GameModel.Instance.SoulCamInit = false; break; default: response = "KO"; return(false); } response = "OK:" + player.Id; return(true); }
private void ConfigureConnection(IServerEndpoint endpoint, IRemoteConnection clientConnection) { clientConnection.OperationDispatcher .RegisterHandler <ICalculator>(new Calculator()) .RegisterHandler <IGreeter>(new Greeter()) .RegisterHandler <IRemoteService>(new RemoteService(clientConnection, endpoint.BroadcastRemoteExecutor)); }
public SapIntegrationHandlerServer( IRemoteConnection remoteConnection, ILogger parentLogger, IHandlerContainer handlerContainer) : base(remoteConnection, parentLogger, SapIntegrationHandlerServerInfo.HandlerName, handlerContainer) { _handlerInfo = new SapIntegrationHandlerServerInfo(); }
public ScenarioDataPerGraph(string name, IRemoteConnection connection, IDictionary <string, Vertex> vertices, IDictionary <string, Edge> edges) { Name = name; Connection = connection; Vertices = vertices; Edges = edges; }
private void ExecuteDispose() { var conn = _conn; _conn = null; conn.Dispose(); _state = ConnectionState.Disposed; }
public ArchiveHandlerServer( IRemoteConnection remoteConnection, ILogger parentLogger, IHandlerContainer handlerContainer) : base(remoteConnection, parentLogger, ArchiveHandlerServerInfo.HandlerName, handlerContainer) { _handlerInfo = new ArchiveHandlerServerInfo(); }
private static void Disconnected(IRemoteConnection remote, string justification) { var player = PLAYERS[remote]; GlobalServer.Instance.RemovePlayer(player.Id); PLAYERS.Remove(remote); Console.WriteLine("disconnected ({0} - {1})", player.Id, player.Name); }
protected override void InitializeConnection(IRemoteConnection connection) { var remoteExecutor = connection.RemoteExecutor; var twoWayCallback = Aspects.WithTimeMeasure(remoteExecutor.Create <IClientCallback>(ReturnPolicy.TwoWay), ConsoleColor.DarkCyan); var oneWayCallback = Aspects.WithTimeMeasure(remoteExecutor.Create <IClientCallback>(ReturnPolicy.OneWay), ConsoleColor.DarkCyan); var longRunningOperation = Aspects.WithTimeMeasure <ILongRunningOperation>(new LongRunningOperation(twoWayCallback, oneWayCallback)); connection.OperationDispatcher.RegisterHandler(longRunningOperation); }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionEventArgs" /> class. /// </summary> /// <param name="conn">The value for the <see cref="ConnectionEventArgs.Connection" /> property.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="conn" /> is <see langword="null" />. /// </exception> public ConnectionEventArgs(IRemoteConnection conn) { if (conn == null) { throw new ArgumentNullException("conn"); } this.Connection = conn; }
protected override void InitializeConnection(IRemoteConnection connection) { var clientContext = new ClientContext(); _sharedContext.AddClient(connection, clientContext); connection.OperationDispatcher .RegisterHandler <IRegistrationService>(new RegistrationService(clientContext)) .RegisterHandler <IUserInfoService>(new UserInfoService(_sharedContext, clientContext)); }
/// <summary> /// Initializes a new instance of the <see cref="ClientConnection" /> class. /// </summary> /// <param name="settings">The value for the <see cref="ApplicationObject.Settings" /> property.</param> /// <param name="connection">The value for the <see cref="ClientConnection.Connection" /> property.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="connection" /> is <see langword="null" />. /// </exception> /// <exception cref="NullReferenceException"> /// <paramref name="settings" /> is <see langword="null" />. /// </exception> protected ClientConnection(IAppSettings settings, IRemoteConnection connection) : base(appContext: settings.Application) { if (connection == null) { throw new ArgumentNullException("connection"); } this.Connection = connection; }
protected void OnConnectionClose(IRemoteConnection connection) { var user = _sharedContext.GetUser(connection); _sharedContext.RemoveClient(connection); if (user.IsRegistered) { _broadcastService.UserLeft(user.Name); } }
public Innovator.Client.IOM.Innovator GetInnovator() { if (this.Inn == null) { IRemoteConnection conn = Innovator.Client.Factory.GetConnection(Url, "ArasDevTool"); conn.Login(new ExplicitCredentials(DB, User, Password)); Inn = new Innovator.Client.IOM.Innovator(conn); } return(Inn); }
/// <summary> /// Initializes a new instance of the <see cref="GraphTraversalSource"/> class. /// </summary> public GraphTraversalSource(IRemoteConnection remote = null) { _graphTraversalSource = AnonymousTraversalSource.Traversal(); _graphTraversalSource.Bytecode.AddSource("g"); if (remote != null) { _graphTraversalSource = _graphTraversalSource.WithRemote(remote); } }
/// <summary> /// Sends that record over a remote connection. /// </summary> /// <param name="conn">The connection.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="conn" /> is <see langword="null" />. /// </exception> public void SendTo(IRemoteConnection conn) { if (conn == null) { throw new ArgumentNullException("conn"); } var blob = this.ToByteArray(); conn.Stream.Write(blob, 0, blob.Length); }
private static void Disconnected(IRemoteConnection remote, string justification) { var player = PLAYERS[remote]; World.Instance.RemovePlayer(player.Id); GlobalServer.Instance.RemoveBattle(player.Id); GlobalServer.Instance.RemovePlayer(player.Id); PLAYERS.Remove(remote); Console.WriteLine("disconnected ({0} - {1})", player.Id, player.Name); }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionWithClient" /> class. /// </summary> /// <param name="host">The value for the <see cref="ConnectionWithClient.Host" /> property.</param> /// <param name="conn">The value for the <see cref="ConnectionWithClient.Connection" /> property.</param> /// <param name="sync">The value for the <see cref="NotifiableBase.SyncRoot" /> property.</param> public ConnectionWithClient(ServerHost host, IRemoteConnection conn, object sync = null) : base(appContext: host.Application, sync: sync) { if (conn == null) { throw new ArgumentNullException("conn"); } this.Host = host; this.Connection = conn; }
public Player(string name, IRemoteConnection remote, PlayerType type) { Name = name; Id = sequenceId++; RemoteConnection = remote; Type = type; Position = new Position(0, 0); MovingUp = false; MovingDown = false; MovingLeft = false; MovingRight = false; }
protected override void InitializeConnection(IRemoteConnection connection) { var userContext = new ClientContext(); _sharedContext.AddClient(connection, userContext); var registrationService = Aspects.WithTimeMeasure <IRegistrationService>(new RegistrationService(userContext, _broadcastService)); var userInfoService = Aspects.WithTimeMeasure <IUserInfoService>(new UserInfoService(_sharedContext, userContext)); connection.OperationDispatcher .RegisterHandler(registrationService) .RegisterHandler(userInfoService); }
private static bool ConnectionRequested(IRemoteConnection sender, string request, out string response) { Player player = new Player(request, sender); //player.Position = new Position(200, 150); player.Position = new Position(200, 175); //player.Position = new Position(35, 35); PLAYERS.Add(sender, player); World.Instance.AddPlayer(player); GlobalServer.Instance.AddPlayer(player.Id, sender); response = "OK:" + player.Id; return true; }
public IPromise <string> Login(ICredentials credentials, bool async) { var mapping = GetMapping(credentials.Database); _lastCredentials = credentials; var credPromise = GetCredentials(mapping, credentials, async); _current = mapping.Connection; if (_settings != null) { _current.DefaultSettings(_settings); } return(credPromise.Continue(cred => _current.Login(cred, async))); }
public Player(string name, IRemoteConnection remote) : base(EntityType.Player, false, true, false) { Name = name; Team = new Team(); MapToUpdate = true; TeamToUpdate = true; LastMove = DateTime.Now; MoveInputDelay = 0.30f; RemoteConnection = remote; // DEBUG Team.AddPokemon(new BattleEntity(-1, 1, Id)); Team.AddPokemon(new BattleEntity(-1, 2, Id)); }
private ConnectionPool(IRemoteConnection conn, int size) { _available = new Promise <bool>(); _ref = conn; _pool = new PooledConnection[size]; for (var i = 0; i < size; i++) { var idx = i; conn.Clone(true) .Done(c => { _pool[idx] = new PooledConnection(c); _available.Resolve(true); }); } }
private async void Mtc_RemoteSystemSelected(object sender, IRemoteSystemDescription eventArgs) { RemoteControl remote = new RemoteControl(); IRemoteConnection remoteConnection = await ViewModel.CreateRemoteControl(eventArgs); if (remoteConnection != null) { remote.RemoteConnection = remoteConnection; RemoteControlPopup.Content = remote; remote.CloseClicked += (s, ev) => RemoteControlPopup.Hide(); var result = await RemoteControlPopup.ShowAsync(); } else { await UIHelpers.ShowContentAsync("Connection failed."); } }
private static void MessageReceived(IRemoteConnection sender, string message) { Console.WriteLine("Message received from {0}:{1} : {2}.", sender.IPAddress, sender.Port, message); var player = PLAYERS[sender]; var splitedArgument = message.Split('/'); var cmd = splitedArgument[0]; var args = splitedArgument[1]; ICommand command = CommandFactory.GetCommand(cmd); Object param; if (command.CanRun(player, args, out param)) { Task.Run(() => command.Run(player, param)); } else { Console.WriteLine("Can't run the command {0} with the arguments {1}", cmd, args); } }
public MessageDispatcherImpl(IRemoteConnection sender) { this._sender = sender; sender.MessageReceived += (o, e) => HandleMessage(e.Message); }
public void Logout(bool unlockOnLogout, bool async) { _current?.Logout(unlockOnLogout, async); _current = null; }
public void Logout(bool unlockOnLogout) { _current?.Logout(unlockOnLogout); _current = null; }
public void Logout(bool unlockOnLogout, bool async) { _current.Logout(unlockOnLogout, async); _current = null; }
public void Logout(bool unlockOnLogout) { _current.Logout(unlockOnLogout); _current = null; }
public void AddPlayer(int playerId, IRemoteConnection remote) { playerConnectionMap.Add(playerId, remote); }
private void MessageReceived(IRemoteConnection sender, string message) { messageCount++; if (messageCount < 10) { Debug.Log("received " + message); } var prefix = "entities:"; if (message.StartsWith(prefix) && CurrentScene == "scene_map") { var notif = new PositionMessage(); notif.DeserializeArguments(message.Remove(0, prefix.Length)); foreach (var entity in notif.Entities) { MoveMessages.Enqueue(entity); } } prefix = "team:"; if (message.StartsWith(prefix)) { var teamStr = message.Remove(0, prefix.Length); var pokemonCount = teamStr.Split(',').Count(); Team = new List<Pokemon>(); for (int i = 0; i < pokemonCount; i++) { var pokemonStr = teamStr.Split(',')[i]; var id = Int32.Parse(pokemonStr.Split('.')[0]); var level = Int32.Parse(pokemonStr.Split('.')[1]); Team.Add(new Pokemon(id, level)); } } prefix = "map:"; if (message.StartsWith(prefix)) { Debug.Log("map received"); var map = new MapMessage(); map.DeserializeArguments(message.Remove(0, prefix.Length)); //Debug.Log(map); MapMessages.Enqueue(map); } prefix = "battlestart:"; if (message.StartsWith(prefix)) { Debug.Log("battle start received"); var battleStart = message.Remove(0, prefix.Length); BattleStartMessage battle = new BattleStartMessage(battleStart); BattleStartMessages.Enqueue(battle); } prefix = "battleaction:"; if (message.StartsWith(prefix)) { Debug.Log("battle action received"); var battleActionStr = message.Remove(0, prefix.Length); Debug.Log(battleActionStr); BattleActionMessage battleAction = new BattleActionMessage(battleActionStr); BattleActionMessages.Enqueue(battleAction); } }