public bool TryGetOnlineConnection(UniqueId id, out IClientConnection connection) { lock (_connections) { return(_connections.TryGetValue(id, out connection)); } }
static void Main(string[] args) { ServerList serverList = new ServerList(); var servers = serverList.Refresh(); servers.Wait(); foreach (Server server in servers.Result) { Console.WriteLine(server.Name); } var pings = serverList.Ping(servers.Result.Select(s => s.Address)); pings.Wait(); foreach (PingResult result in pings.Result) { if (result == null) { continue; } Console.WriteLine("{0}: {1}", result.Reply.Status, result.Address); } IClient ircClient = new Client(); IClientConnection connection = ircClient.CreateClientConnection("irc.freenode.net", 6666, null); connection.Connect().Wait(); connection.Login("Harvester", "Harvester", "Harvester").Wait(); connection.Join("#tz"); Console.ReadKey(); }
private void FireServerLoginResultArrived(IClientConnection con, PacketLoginResult result) { if (ServerLoginResultArrivedInvoker != null) { ServerLoginResultArrivedInvoker(con, result); } }
public ServerPlayerModel(PlayerCombatBehaviourBase playerCombatBehaviour, string playerID, string name, EquipmentItemModel equippedWeaponItemModel, EquipmentItemModel equippedOffHandItemModel, EquipmentItemModel equippedArmorItemModel, IClientConnection clientConnection) : base(playerID, name, equippedWeaponItemModel, equippedOffHandItemModel, equippedArmorItemModel) { this.ClientConnection = clientConnection; PlayerCombatBehaviour = playerCombatBehaviour; }
private void FireSocketConnectionConcluded(IClientConnection con, bool result, string msg) { if (SocketConnectionConcludedInvoker != null) { SocketConnectionConcludedInvoker(con, result, msg); } }
//constructor. public LogsModel() { client = WebClient.Instance; client.DataReceived += OnDataRecieved; //SendLogRequest(); }
} //the connection to server. //constructor public ImageWebModel() { Client = ClientConnection.Instance; NumOfPics = 0; IsConnected = Client.IsConnected; Students = StudentsInit(); }
private void onDisconnected(IClientConnection clientConnection) { if (Disconnected != null) { Disconnected(this); } }
public static void Execute(IClientConnection unreadyClientConnection, List <ServerPlayerModel> allServerPlayerModels) { ServerPlayerModel unreadyServerPlayerModel = null; for (int i = 0; i < allServerPlayerModels.Count; i++) { if (allServerPlayerModels[i].ClientConnection == unreadyClientConnection) { unreadyServerPlayerModel = allServerPlayerModels[i]; break; } } // Protect against spam if (!unreadyServerPlayerModel.IsReady) { return; } unreadyServerPlayerModel.IsReady = false; PlayerUnreadyEvent playerUnreadyEvent = new PlayerUnreadyEvent(unreadyServerPlayerModel.PlayerID); for (int j = 0; j < allServerPlayerModels.Count; j++) { if (allServerPlayerModels[j].ClientConnection.Connected) { allServerPlayerModels[j].ClientConnection.SendEvent(playerUnreadyEvent.EventData, playerUnreadyEvent.SendParameters); } } }
public static ISendMessage CreateSendMessage(this IClient client, IClientConnection connection, String prefixHeader, String contents, String postfixHeader, SendType type, params IMessageTarget[] receivers) { return client.CreateSendMessage(connection, prefixHeader, contents, postfixHeader, type, receivers); }
public Bot Create(IClientConnection connection) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (!CanCreate) { var total = _options.BotsPerRoomCount * _options.RoomsCount; throw new InvalidOperationException($"Expected to create maximum of {total} bots."); } var roomIndex = _i / _options.BotsPerRoomCount; var room = $"{_options.RoomPrefix}conreign-load-test-{roomIndex}"; var k = _i % _options.BotsPerRoomCount; var isLeader = _i % _options.BotsPerRoomCount == 0; var name = isLeader ? "leader" : $"bot-{k}"; var id = $"{room}_{name}"; var behaviours = new List <IBotBehaviour> { new LoginBehaviour(), new JoinRoomBehaviour(room, isLeader ? TimeSpan.Zero : _options.JoinRoomDelay), new BattleBehaviour(_battleStrategy), new StopOnGameEndBehaviour() }; if (isLeader) { behaviours.Add(new StartGameBehaviour(_options.BotsPerRoomCount)); } var bot = new Bot(id, connection, behaviours.ToArray()); _i++; return(bot); }
/// <summary> /// Parts given channel name with a message. /// </summary> /// /// <param name="connection"> The connection to act on.</param> /// <param name="channelName">Name of the channel.</param> /// <param name="message"> The part message.</param> public static IChannel Part(this IClientConnection connection, String channelName, String message) { IChannel channel = connection.GetChannel(channelName); connection.SendAndForget(connection.MessageSender.Part(channel, message)); return(channel); }
public static ISendMessage CreateSendMessage(this IClient client, IClientConnection connection, String prefixHeader, String contents, String postfixHeader, SendType type, params IMessageTarget[] receivers) { return(client.CreateSendMessage(connection, prefixHeader, contents, postfixHeader, type, receivers)); }
private void onJoinRoomRequestReceived(OperationRequest operationRequest, IClientConnection clientConnection, SendParameters sendParameters) { JoinRoomOpRequest joinRoomOpRequest = JoinRoomOpRequest.FromOperationRequest(operationRequest); // validate client's session new ValidateSessionCMD(joinRoomOpRequest, clientConnection, sessionValidatedHandler, sessionValidationFailedHandler).Execute(); }
public BufferClientOnceApiConvert(IClientConnection connection, ILogger logger) { _connection = connection; _logger = logger; _connection.ReceivedAsync += ConnectionReceivedAsync; _connection.ReceiveDisconnected += ConnectionReceiveDisconnected; }
/// <summary> /// Kicks a user with given user name from this channel with a reason. /// </summary> /// /// <param name="channel"> The channel to act on.</param> /// <param name="userName">Name of the user.</param> /// <param name="reason"> The reason.</param> public static void Kick(this IChannel channel, String userName, String reason) { IClientConnection connection = channel.Connection; IChannelUser channelUser = channel.GetUser(userName); connection.SendAndForget(connection.MessageSender.Kick(channelUser, reason)); }
/// <summary> /// MainWindowModel Constructor /// </summary> public MainWindowModel() { //creates an instance of client connection //Checks if connected client_connection = ClientConnection.Instance; IsConnected = client_connection.IsConnected; }
private void serverConnection_OnClientConnected(object sender, IClientConnection e) { // Create new player object var player = new Player(creatureDataProvider, e); GlobalManager.GetManager <CreatureManager>().AddPlayer(player); }
public ChannelUser(IClientConnection connection, IChannel channel, IUser user) { Connection = connection; Channel = channel; User = user; Modes = new Mode(); }
private void recConn() { //topic需要与发布端topic一致 info = new ClientInfo(); info.setUser("MDT.Tools", "test"); //设置AMQIII的IP地址和端口号,可根据实际情况进行设置 info.setAddress("192.168.2.122/mq.httpMQTunnel", 19990); info.Protocol = ClientInfo.PROTOCOL_HTTP; try { info.LoginMessage = getLoginMsg("admin", "UOBS", "111111", ""); // 创建连接 conn = ClientConnectionFactory.createConnection(info); conn.addEventListener(this); conn.setLoginListener(this); conn.start(); // 订阅topic,接收消息 session = conn.createSession(); } catch (Exception e) { LogHelper.Error(e); } }
public bool RejoinPlayer(PlayerAuthenticationModel playerAuthModel, IClientConnection clientConnection) { if (isGameCompleted) { Log.Info("Can't rejoin player, game is completed."); return(false); } ServerPlayerModel originalServerPlayerModel; originalPlayerIDToModel.TryGetValue(playerAuthModel.UserID, out originalServerPlayerModel); if (originalServerPlayerModel == null) { return(false); } // If the player is still connected through a previous connection, disconnect it. if (originalServerPlayerModel.ClientConnection.Connected) { originalServerPlayerModel.ClientConnection.Disconnect(); } originalServerPlayerModel.IsRejoining = true; originalServerPlayerModel.ClientConnection = clientConnection; // Replace stale connection Log.Info("Sending rejoining player SendLoadWorldEventsCMD"); new SendLoadWorldEventsCMD(worldModel, new List <ServerPlayerModel>(new ServerPlayerModel[] { originalServerPlayerModel }), onPlayersLoadedWorld).Execute(); return(true); }
public void ConnectionLimitRestartListening() { IServerConnection connection = null; provider.ConnectionMade += (sender, e) => { if (connection == null) { connection = e.Connection; } }; ConnectionLimit(); Assert.IsNotNull(connection); connection.DisconnectAsync(); AsyncTest test = new AsyncTest(); provider.ConnectionMade += test.PassHandler; IClientConnection client = GetNewClientConnection(); client.Disconnected += test.FailHandler; client.ConnectAsync(Target, MessageTypes); test.Assert(10000); }
public void SpawnNpcs(IClientConnection client, TimeSpan sinceLastEncounter, double oddsOfEncounter, AggressionModel?aggressionModel = null) { var location = client.Location; var character = client.Character; if (aggressionModel is null) { aggressionModel = Calculator.GetRandomEnum <AggressionModel>(); } if (character.State == CharacterState.Normal && !location.IsSafeArea && DateTimeOffset.Now - character.LastCombatEncounter >= sinceLastEncounter && !location.Npcs.Any(x => !x.IsFriendly)) { var spawn = Calculator.RollForBool(oddsOfEncounter); if (!spawn) { return; } var locationPlayerCount = location.PlayersAlive.Where(x => x.State != CharacterState.InCombat); var npcsToSpawn = Calculator.RandInstance.Next(0, locationPlayerCount.Count() + 2); for (var i = 0; i < npcsToSpawn; i++) { location.AddCharacter(_npcService.GenerateRandomNpc(aggressionModel, location)); } _combatService.InitiateNpcAttackOnSight(client); } }
private void DisconnectCore(DisconnectionReason reason, IClientConnection connection, bool reconnect, bool fireEvent) { lock (StateSync) { disconnectedInChannelId = CurrentUser.CurrentChannelId; this.connecting = false; this.running = false; this.formallyConnected = false; CurrentUser = new CurrentUser(this); this.Users.Reset(); this.Channels.Clear(); this.Sources.Reset(); this.Audio.Stop(); connection.DisconnectAsync(); if (fireEvent) { OnDisconnected(this, new DisconnectedEventArgs(reason)); } if (reconnect) { this.connecting = true; ThreadPool.QueueUserWorkItem(Reconnect); } } }
private async void OnClientConnected(object sender, IClientConnection e) { using (await _clientConnectedLock.LockAsync()) { await(await _sessionTrigger).InvokeClient(e.ClientId); } }
internal IRouter GetByConnection(IClientConnection pConnection) { IRouter objRouter = null; if (RouterPerConnectionID.ContainsKey(pConnection.ID)) { if (RouterPerConnectionID.TryGetValue(pConnection.ID, out objRouter)) { return(objRouter); } else { //ToDo: logging } } var obj = new Router(MainQueue, RequestManager, pConnection); obj.Disconnected += Router_Disconnected; if (!RouterPerConnectionID.TryAdd(pConnection.ID, obj)) { //ToDo: logging } if (!RouterByID.TryAdd(obj.ConnectionID, obj)) { //ToDo: logging } return(obj); }
/// <summary> /// Kicks a user with given user from this channel. /// </summary> /// /// <param name="channel">The channel to act on.</param> /// <param name="user"> The user.</param> public static void Kick(this IChannel channel, IUser user) { IClientConnection connection = channel.Connection; IChannelUser channelUser = channel.GetUser(user.Name); connection.SendAndForget(connection.MessageSender.Kick(channelUser)); }
public PropertyService(IConfiguration configuration, IClientConnection clientConnection, ILogger <PropertyService> logger) { _configuration = configuration; _apiClient = clientConnection; _logger = logger; ApiBaseUrl = _configuration.GetValue <string>("WebAPIBaseUrl"); }
/// <summary> /// 初始化 /// </summary> /// <param name="connectstring"> /// 连接字符串(格式:127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002) /// </param> /// <param name="sessionTimeout">会话超时时间</param> /// <param name="watcher"> /// 接收节点监听通知对象 /// </param> public ZooKeeper(string connectstring, TimeSpan sessionTimeout, IWatcher watcher) { log.InfoFormat("Initiating client connection, connectstring={0} sessionTimeout={1} watcher={2}", connectstring, sessionTimeout, watcher); watchManager.DefaultWatcher = watcher; cnxn = new ClientConnection(connectstring, sessionTimeout, this, watchManager); cnxn.Start(); }
private async void onQRCodeConnectClicked(object sender, EventArgs e) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var scanResult = await scanner.Scan(); if (scanResult != null && scanResult.Text != "") { var connectInfo = Connection.DecodeBluetoothConnection(scanResult.Text); Guid guid = connectInfo.Guid; IBluetoothDevice bluetoothDevice = DependencyService.Get <IBluetoothManager>().GetBluetoothDevice(connectInfo.DeviceAddress); IConnectionManager connectionManager = DependencyService.Get <IConnectionManager>(); IClientConnection currentConnection = connectionManager.ControllerConnection as IClientConnection; ConnectionEstablishState connectState = ConnectionEstablishState.Failed; IClientConnection connection = DependencyService.Get <IBluetoothManager>().CreateRfcommClientConnection(bluetoothDevice, guid); if (connectionManager.ControllerConnection != null) { bool result = await DisplayAlert("Connect", "Stop Current Connection ?", "Yes", "No"); if (result) { if (currentConnection.ConnectionEstablishState == ConnectionEstablishState.Connecting) { currentConnection.AbortConnecting(); } } } connectionManager.ControllerConnection = connection; connectState = await connection.ConnectAsync(); } }
private async void onConnectClicked(object sender, EventArgs e) { if (_SelectedGuid == null) { Debug.WriteLine("NO UUID SELECTED"); return; } IConnectionManager connectionManager = DependencyService.Get <IConnectionManager>(); IClientConnection currentConnection = connectionManager.ControllerConnection as IClientConnection; ConnectionEstablishState connectState = ConnectionEstablishState.Failed; IClientConnection connection = DependencyService.Get <IManagerManager>().BluetoothManager.CreateRfcommClientConnection(_BluetoothDevice, (Guid)_SelectedGuid); if (connectionManager.ControllerConnection != null) { bool result = await DisplayAlert("Connect", "Stop Current Connection ?", "Yes", "No"); if (result) { if (currentConnection.ConnectionEstablishState == ConnectionEstablishState.Connecting) { currentConnection.AbortConnecting(); } } } connectionManager.ControllerConnection = connection; connectState = await connection.ConnectAsync(); if (connectState == ConnectionEstablishState.Succeeded) { } }
public Session(string target, IConnectionManager connectionManager) { this.connectionManager = connectionManager; this.Target = target; this.Name = target; this.connection = connectionManager.GetClientConnection(target); if (connection == null) { connection = connectionManager.AddClientConnection(target); connection.ConnectionReset += connection_ConnectionReset; connection.ConnectionTimedOut += connection_ConnectionTimedOut; connection.RemoteErrorOccurred += connection_RemoteErrorOccurred; } //authComponent = (AuthenticationComponent)connection.GetClientComponent(ComponentNamesExtended.Authentication); //clientInfoComponent = (ClientInfoClientComponent)connection.GetClientComponent(ComponentNamesExtended.ClientInfoProvider); //loggingConfigurator = (XmppLoggingConfiguratorComponent)connection.GetClientComponent(ComponentNamesExtended.XmppLoggingConfigurator); //fileShareComponent = (FileShareClientComponent)connection.GetClientComponent(ComponentNamesExtended.FileShare); authComponent = new AuthenticationComponent() { ClientConnection = connection }; clientInfoComponent = new ClientInfoClientComponent() { ClientConnection = connection }; loggingConfigurator = new XmppLoggingConfiguratorComponent() { ClientConnection = connection }; fileShareComponent = new FileShareClientComponent() { ClientConnection = connection }; //CommandInfo info = new CommandInfo(); commands.Add("get-status", new CommandInfo() { ParameterCount = 0, CommandMethod = getStatusCommand, CheckConnection = false}); commands.Add("connect", new CommandInfo() { ParameterCount = 0, CommandMethod = connectCommand, CheckConnection = false }); commands.Add("disconnect", new CommandInfo() { ParameterCount = 0, CommandMethod = disconnectCommand }); commands.Add("userauth", new CommandInfo() { ParameterCount = 1, CommandMethod = userauthCommand }); commands.Add("get-info", new CommandInfo() { ParameterCount = 0, CommandMethod = getInfoCommand }); commands.Add("exit-session", new CommandInfo() { CheckConnection=false, ParameterCount = 0, CommandMethod = exitSessionCommand }); commands.Add("logger.get-enabled", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetEnabledCommand }); commands.Add("logger.set-enabled", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetEnabledCommand }); commands.Add("logger.get-loglevel", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetLogLevelCommand }); commands.Add("logger.set-loglevel", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetLogLevelCommand }); commands.Add("logger.get-recipient", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetRecipientCommand }); commands.Add("logger.set-recipient", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetRecipientCommand }); commands.Add("logger.get-debuglogging", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetDebugLoggingCommand }); commands.Add("logger.set-debuglogging", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetDebugLoggingCommand }); commands.Add("logger.test-logging", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerTestLoggingCommand }); commands.Add("fileshare.add-directory", new CommandInfo() { ParameterCount = 2, CommandMethod = fileshareAddDirectoryCommand }); commands.Add("fileshare.remove-directory", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareRemoveDirectoryCommand }); commands.Add("fileshare.get-directory", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareGetDirectoryCommand }); commands.Add("fileshare.get-file", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareGetFileCommand }); commands.Add("fileshare.add-permission", new CommandInfo() { ParameterCount = -2, CommandMethod = fileshareAddPermissionCommand }); commands.Add("fileshare.remove-permission", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareRemovePermissionCommand }); commands.Add("fileshare.get-mounts", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetMountsCommand }); commands.Add("fileshare.check-permission", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareCheckPermissionCommand }); commands.Add("fileshare.get-permissions", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetPermissionsCommand }); commands.Add("fileshare.get-rootdirectory", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetRootDirectoryCommand }); commands.Add("fileshare.set-rootdirectory", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareSetRootDirectoryCommand }); commands.Add("fileshare.create-snapshot", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareCreateSnapshotCommand }); commands.Add("fileshare.get-snapshots", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetSnapshotsCommand }); }
public static void SendAlertMessage(string message, IClientConnection client) { WriteBuffer buffer = new WriteBuffer(); buffer.Write(1); // type buffer.Write(message); client.Send(buffer.SerializeAndWriteSize()); }
public void CreateServer(IContext context, IClientConnection server, String identifier) { IStorage storage = context.Bot.Storage.Server(context.Command.Plugin, server); List<object> list = storage.Get<List<object>>(identifier); if(list != null) throw new ArgumentException("List with given identifier already exists for given server.", "identifier"); storage.Set(new List<object>(), identifier); }
public SendMessage(IClientConnection connection, String prefixHeader, String contents, String postfixHeader, SendType type, IEnumerable<IMessageTarget> receivers) { Connection = connection; PrefixHeader = prefixHeader; Contents = contents; PostfixHeader = postfixHeader; _receivers = new HashSet<IMessageTarget>(receivers); Type = type; }
public ReceiveMessage(IClientConnection connection, String contents, DateTime date, IMessageTarget sender, IMessageTarget receiver, ReceiveType type, ReplyType replyType) { Connection = connection; Contents = contents; Date = date; Sender = sender; Receiver = receiver; Type = type; ReplyType = replyType; }
public ClientMainService(IClientConnection connection, ISharedDataService data, ISettings settings, IPropertyChangedTransmitter transmitter, IPropertyChangedReceiver receiver, INavigationService navigation) { _connection = connection; _data = data; _settings = settings; _transmitter = transmitter; _receiver = receiver; _navigation = navigation; }
public CincoClient(IClientConnection connection) : base(connection, MessageTypes.Reliable) { CincoProtocol.Protocol.Discover (typeof (CincoMessageBase).Assembly); this.snapshotManager = new SnapshotManager (10); this.entities = new List<NetworkEntity> (); this.entityMap = new Dictionary<uint, NetworkEntity> (); this.entityTypeInformation = new Dictionary<string, EntityInformation> (); TickRate = new TimeSpan (0, 0, 0, 0, 15); this.RegisterMessageHandler<EntitySnapshotMessage> (OnEntitySnapshotMessage); this.RegisterMessageHandler<ServerInformationMessage> (OnServerInformationMessage); }
public void ExecuteCore(ReadBuffer request, IClientConnection client, IClientsManager clientsManager) { Request = request; Client = client; ClientsManager = clientsManager; try { Execute(); } catch (Exception) { } }
public BotClientConnection(IBot bot, IClientConnection connection, MessageHandler messageHandler, ConnectionData data) { Bot = bot; Connection = connection; _messageHandler = messageHandler; _data = data; // Subscribe to received messages. _messageSubscription = Connection.ReceivedMessages .Where(m => !m.Sender.Equals(connection.Me)) .Where(m => m.Type == ReceiveType.Message || m.Type == ReceiveType.Notice || m.Type == ReceiveType.Action) .Where(m => m.Sender.Type == MessageTargetType.User || m.Sender.Type == MessageTargetType.ChannelUser) .Subscribe(_messageHandler.ReceivedMessage); }
public SocialClient (IClientConnection connection, Person persona) : base (connection, MessageTypes.Reliable) { if (persona == null) throw new ArgumentNullException ("persona"); this.watchList = new WatchList (this); this.persona = persona; this.persona.PropertyChanged += OnPersonaPropertyChanged; this.RegisterMessageHandler<RequestBuddyListMessage> (OnRequestBuddyListMessage); this.RegisterMessageHandler<GroupInviteMessage> (OnGroupInviteMessage); this.RegisterMessageHandler<GroupUpdateMessage> (OnGroupUpdatedMessage); this.RegisterMessageHandler<TextMessage> (OnTextMessage); this.RegisterMessageHandler<ConnectionInfoMessage> (OnConnectionInfoMessage); }
public Channel(IClientConnection connection, String name, SynchronizationContext context) { _context = context; _users = new SynchronizedKeyedCollection<String, IChannelUser>(_context); _knownUsers = new SynchronizedKeyedCollection<String, IChannelUser>(_context); Connection = connection; Name = new ObservableProperty<String>(name); Modes = new Mode(); Topic = new ObservableProperty<String>(String.Empty); TopicSetBy = new ObservableProperty<IUser>(null); TopicSetDate = new ObservableProperty<uint>(0); CreatedDate = new ObservableProperty<uint>(0); ReceivedMessages = connection.ReceivedMessages .Where(m => m.Receiver.Equals(this)) ; }
public User(IClientConnection connection, String name, SynchronizationContext context) { _context = context; _channels = new SynchronizedKeyedCollection<String, IChannel>(_context); _knownChannels = new SynchronizedKeyedCollection<String, IChannel>(_context); Connection = connection; Identity = new Identity(name, null, null); RealName = new ObservableProperty<String>(String.Empty); Network = new ObservableProperty<INetwork>(null); Modes = new Mode(); Away = new ObservableProperty<bool>(false); Name = new ObservableProperty<String>(name); ReceivedMessages = connection.ReceivedMessages .Where(m => m.Receiver.Equals(this)) ; SentMessages = connection.ReceivedMessages .Where(m => m.Sender.Equals(this)) ; }
protected void RaiseOnPacketReceived(IClientConnection clientConnection, byte[] buffer) { if (OnPacketReceived != null) OnPacketReceived(clientConnection, buffer); }
private String ServerString(IClientConnection connection) { return connection.Address + "_" + connection.Port; }
private IStorage OpenServer(IPlugin plugin, IClientConnection connection) { IOpenableStorage storage = NewStorage(); storage.Open(Path.Combine(_path, ServerString(connection), PluginString(plugin) + _extension)); return storage; }
public IStorage Server(IPlugin plugin, IClientConnection connection) { return _pluginServer.GetOrCreate(Tuple.Create(plugin, connection), () => OpenServer(plugin, connection)); }
public IStorage Server(IClientConnection connection) { return _server.GetOrCreate(connection, () => OpenServer(connection)); }
public IStorage PluginStorage(IPlugin plugin, IClientConnection connection = null, IChannel channel = null) { IStorage storage = new NestedStorage(Global(plugin), null); if(connection != null) { storage = new NestedStorage(Server(plugin, connection), storage); } if(channel != null) { storage = new NestedStorage(Channel(plugin, channel), storage); } return storage; }
public ScreenshareClient(IClientConnection connection) : base(connection, MessageTypes.Reliable) { this.RegisterMessageHandler<ScreenFrameResponseMessage>(OnScreenFrameMessage); }
public MockClientContext(IClientConnection connection) : base(connection, MessageTypes.All, false) { }
public ClientInfoClientComponent(IClientConnection clientConnection = null) { this.ClientConnection = clientConnection; }
public TempestClient(IClientConnection connection, MessageTypes mtypes) { if (connection == null) throw new ArgumentNullException ("connection"); if (!Enum.IsDefined (typeof (MessageTypes), mtypes)) throw new ArgumentException ("Not a valid MessageTypes value", "mtypes"); this.messageTypes = mtypes; this.connection = connection; this.connection.Connected += OnConnectionConnected; this.connection.Disconnected += OnConnectionDisconnected; this.mqueue = new ConcurrentQueue<MessageEventArgs>(); this.connection.MessageReceived += ConnectionOnMessageReceived; }
public ClientMeetingViewModel( IClientConnection clientConnection, INavigationService navigation, ISharedDataService sharedDataService, IPlatformServices platformServices) { _sharedDataService = sharedDataService; _clientConnection = clientConnection; _navigation = navigation; // Combine the meeting details and IsActive to know when to go back // We should go back when we are the active screen (IsActive == true) // and the Meeting Details are cleared out - will be null. _navSub = _clientConnection.MeetingDetails .CombineLatest(this.WhenAnyValue(vm => vm.IsActive), (det, act) => new { Details = det, IsActive = act }) // combine into anon type .Where(t => t.IsActive && t.Details == null) .Subscribe(c => _navigation.BackCommand.Execute(null)); Title = "Welcome to White Label Insurance"; // Listen for state changes from the shared model // and return the non-null ids var stateObs = sharedDataService.MeetingState .WhenAnyValue(s => s.State) .Where(s => s.HasValue) .Select(s => s.Value); // de-Nullable<T> the value since we're not null // Get the latest non-null meeting var meetingObs = this.ObservableForProperty(vm => vm.Meeting, m => m) .Where(v => v != null); // Get the latest MeetingState and combine it with the current Meeting meetingObs .CombineLatest(stateObs, Tuple.Create) // store the latest in a tuple .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => { // for clarity, extract the tuple var state = t.Item2; var meeting = t.Item1; // Fet the specififed tool instance by id var activeTool = meeting.Tools.First(tool => tool.ToolId == state.ToolId); // Navigate to the current page within the tool activeTool.GoToPage(state.PageNumber); // Finally, set the tool to be the active one for the meeting meeting.ActiveTool = activeTool; } ); var leaveMeetingCommand = new ReactiveCommand(); leaveMeetingCommand.Subscribe(_ => _navigation.BackCommand.Execute(null)); LeaveMeetingCommand = leaveMeetingCommand; _pdfAvailableSub = _clientConnection.PdfAvailable.ObserveOn(RxApp.MainThreadScheduler).Subscribe(async p => { var result = await _clientConnection.GetIllustrationPdfAsync(p); await platformServices.SaveAndLaunchFile(new System.IO.MemoryStream(result), "pdf"); }); }
/// <summary> /// Initializes a new instance of CoreClientComponent /// </summary> /// <param name="clientConnection">The ClientConnection used by the component</param> public CoreClientComponent(IClientConnection clientConnection) { this.ClientConnection = clientConnection; }
/// <summary> /// Raises the ClientConnectionAdded event with the specified IClientConnection /// </summary> /// <param name="newConnection">The connetion that has been added</param> protected virtual void onClientConnectionAdded(IClientConnection newConnection) { logger.Info("Client-Connection added: {0}", newConnection.Target); if (this.ClientConnectionAdded != null) { this.ClientConnectionAdded(this, new ObjectEventArgs<IClientConnection>(newConnection)); } }
public ClientConnectionEventArgs(IClientConnection connection) { _connection = connection; }