Exemplo n.º 1
0
        private void HandleClientJoinGroup(int connectionId, byte[] data)
        {
            try
            {
                IRepository repository = _serviceProvider.GetRequiredService <IRepository>();
                ChatApplicationUserLogic chatApplicationUserLogic = new ChatApplicationUserLogic(repository);

                ByteBuffer buffer = new ByteBuffer();
                buffer.WriteBytes(data);
                int packetIdentify = buffer.ReadInteger();
                //In the server side you now send a string as next so you have to read out the string as next.
                string appId             = buffer.ReadString();
                string userEmail         = buffer.ReadString();
                string groupCreatorEmail = buffer.ReadString();

                (bool, string)response = chatApplicationUserLogic.AddUserToGroup(appId, userEmail, groupCreatorEmail);

                ServerTcp.SendJoinGroupResponseToClient(response.Item1, response.Item2);
            }
            catch (Exception e)
            {
                //todo: log error
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
 public HangfireBackgroundService(IRepository repository, ChatMessageSingletonService chatMessageSingletonService,
                                  ChatMessageLogic chatMessageLogic, ChatApplicationUserLogic chatApplicationUserLogic)
 {
     _repository = repository;
     _chatMessageSingletonService = chatMessageSingletonService;
     _chatMessageLogic            = chatMessageLogic;
     _chatApplicationUserLogic    = chatApplicationUserLogic;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new user if the user does not exist.
        /// Nothing will be returned to the client for now
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="data"></param>
        private void HandleClientCreateChatUser(int connectionId, byte[] data)
        {
            IRepository repository = _serviceProvider.GetRequiredService <IRepository>();
            ChatApplicationUserLogic chatApplicationUserLogic = new ChatApplicationUserLogic(repository);

            ByteBuffer buffer = new ByteBuffer();

            buffer.WriteBytes(data);
            int packetIdentify = buffer.ReadInteger();
            //In the server side you now send a string as next so you have to read out the string as next.
            string appId     = buffer.ReadString();
            string userEmail = buffer.ReadString();
            string username  = buffer.ReadString();

            chatApplicationUserLogic.CreateUser(appId, userEmail, username);
        }