Esempio n. 1
0
 public void Register(Registration message)
 {
     Task.Run(async () =>
     {
         var bufferFile = await GetBufferFile();
         await bufferFile.DeleteAsync();
         await SendToServer(message);
         GetPeerList(new Message());
     }).Wait();
 }
Esempio n. 2
0
        public bool HandleRegistration(UnregisteredConnection unregisteredConnection, Registration message)
        {
            Logger.Info($"Handling the registration of connection {unregisteredConnection}");
            RegisteredClient registeredClient;
            if (Clients.ContainsKey(message.UserId))
            {
                if (Clients.TryGetValue(message.UserId, out registeredClient))
                {
                    Logger.Debug($"Client identified. {registeredClient}");
                }
                else
                {
                    Logger.Warn("Error in retrieving client.");
                    return false;
                }
            }
            else
            {
                registeredClient = new RegisteredClient
                {
                    UserId = message.UserId,
                    Domain = Name,
                    Name = message.Name,
                    Avatar = Clients.Count + 1
                };
                registeredClient.OnConnected += RegisteredClient_OnConnected;
                registeredClient.OnDisconnected += RegisteredClient_OnDisconnected;
                registeredClient.OnGetPeerList += RegisteredClient_OnGetPeerList;
                registeredClient.OnRelayMessage += RegisteredClient_OnRelayMessage;

                if (Clients.TryAdd(registeredClient.UserId, registeredClient))
                {
                    Logger.Info($"Registered new client. {registeredClient}");
                }
                else
                {
                    Logger.Warn("Could not register new client.");
                    return false;
                }
            }

            registeredClient.SetActiveConnection(unregisteredConnection, message);
            return true;
        }
Esempio n. 3
0
 public void Register(Registration message)
 {
     _signalingClient.Register(message);
 }
Esempio n. 4
0
 private void UnregisteredConnection_OnRegister(UnregisteredConnection sender, Registration message)
 {
     var domain = GetOrAddDomain(message.Domain);
     UnregisteredConnection connection;
     UnregisteredConnections.TryRemove(sender.Id, out connection);
     connection.OnRegister -= UnregisteredConnection_OnRegister;
     domain.HandleRegistration(connection, message);
 }
 public void Register(Registration message)
 {
     ServerConfirmation(Confirmation.For(message));
     OnRegister?.Invoke(this, message);
 }
Esempio n. 6
0
 public void Register(Registration message)
 {
 }
Esempio n. 7
0
        public void SetActiveConnection(UnregisteredConnection connection, Registration message)
        {
            Logger.Debug("Handling new TCP connection.");

            ConnectionId = Guid.NewGuid();
            ActiveConnection = connection.TcpClient;

            RegisterClientForPushNotifications(message.PushNotificationChannelURI);

            OnRegistrationConfirmation(new RegisteredReply
            {
                Avatar = Avatar,
                ReplyFor = message.Id
            });
            ResetQueues();
            StartReading();
            StartWriting();
            IsOnline = true;
            StartMessageQueueProcessing();
            OnConnected?.Invoke(this);
        }
 public void Register(Registration request)
 {
     _userId = request.UserId;
     SendToServer(request);
 }
Esempio n. 9
0
 public async void Register(Registration message)
 {
     var bufferFile = await GetBufferFile();
     await bufferFile.DeleteAsync();
     await SendToServer(message);
 }