예제 #1
0
        private void OnRequest(Sockets.Plugin.Abstractions.ITcpSocketClient sender, ResponseRequest e)
        {
            var response = new ResponseRequest { Command = e.Command, Status = MessageStatus.Success, Data = 123 };

            switch (e.Command)
            {
                case Commands.Login:
                    break;

                case Commands.CreateUser:
                    break;

                case Commands.JoinRoom:
                    break;

                case Commands.ListRooms:
                    break;

                case Commands.CreateRoom:
                    break;

                case Commands.InviteUser:
                    break;

                case Commands.FindUser:
                    response.Data = new User { Name = "Justin", Id = 12424324 };
                    break;

                default:
                    response.Status = MessageStatus.Fail;
                    break;
            }

            this.server.NotifyClient(sender, response);
        }
예제 #2
0
        public ChatResponse GetResponse(ResponseRequest responseRequest)
        {
            if (responseRequest.requestTime == null)
            {
                responseRequest.requestTime = DateTime.Now;
            }

            var queueItem = new ConversationQueueItem {
                ConversationName = responseRequest.conversationName, RequestTime = responseRequest.requestTime
            };

            if (!ConversationTracker.requestQueue.Any(i => i.ConversationName == queueItem.ConversationName && i.RequestTime == queueItem.RequestTime))
            {
                ConversationTracker.requestQueue.Enqueue(queueItem);
            }

            ConversationQueueItem peekedQueueItem;

            if (ConversationTracker.requestQueue.TryPeek(out peekedQueueItem))
            {
                if (peekedQueueItem.ConversationName == queueItem.ConversationName && peekedQueueItem.RequestTime == queueItem.RequestTime)
                {
                    var conversation = conversationService.GetConversation(responseRequest.conversationName, responseRequest.type);
                    var response     = botService.GetChatResponse(conversation, responseRequest.exclusiveTypes, responseRequest.requiredProperyMatches, responseRequest.excludedTypes, responseRequest.subjectGoals);
                    ConversationTracker.requestQueue.TryDequeue(out peekedQueueItem);

                    return(response);
                }
                CleanQueue();
            }
            return(Task.Delay(queueDelay).ContinueWith((task) => { return GetResponse(responseRequest); }).Result);
        }
예제 #3
0
        public virtual async Task <ActionResult <ResponseDto> > Create([FromBody] ResponseRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dto = await _responseService.CreateEntityAsync(request);

            if (dto == null)
            {
                return(StatusCode(500));
            }
            var userFeedback = request.Feedback.User;

            if (userFeedback != null)
            {
                var notificationRequest = new NotificationRequest
                {
                    Text           = request.Text,
                    CreatedAt      = request.CreatedAt,
                    UserId         = userFeedback.Id,
                    OrganizationId = userFeedback.LastPickedOrganizationId,
                    Type           = NotificationType.Info
                };

                await _notificationService.CreateEntityAsync(notificationRequest);
            }
            else
            {
                await _emailProvider.SendMessageOneToOne("*****@*****.**", "Thanks for feedback", request.Feedback.Email,
                                                         request.Text, "");
            }
            return(CreatedAtAction("GetById", new { id = dto.Id }, dto));
        }
 public bool ValidRequest(ResponseRequest chat)
 {
     if (string.IsNullOrWhiteSpace(chat.conversationName) || string.IsNullOrWhiteSpace(chat.type))
     {
         return(false);
     }
     return(true);
 }
 private void RegisterSlotReservation()
 {
     _reservationService.InsertSlotReservation(_model.Slot);
     _reserved[0] = true;
     ResponseRequest.Raise(new DataPassingNotification {
         Model = _model.Slot
     });
     RegisterSlotReservationCommand.RaiseCanExecuteChanged();
 }
예제 #6
0
        public void NotifyClients(ResponseRequest message)
        {
            var buffer = message.ToByteArray();

            foreach (var client in this.clients.Where(x => x.WriteStream.CanWrite))
            {
                this.Send(client, buffer);
            }
        }
예제 #7
0
        protected void IssueResponse(ResponseRequest responseRequest, int session)
        {
            NetworkConnection connection = ClientConnections[session];

            if (connection != null)
            {
                connection.IssueResponse(responseRequest);
            }
        }
 private void RegisterSeriesReservation()
 {
     _reservationService.InsertSeriesReservation(_model.Series);
     _reserved[1] = true;
     ResponseRequest.Raise(new DataPassingNotification {
         Model = new WrapSeries(_model.Series)
     });
     RegisterSeriesReservationCommand.RaiseCanExecuteChanged();
 }
예제 #9
0
        private ResponseRequest getResponseRequest(ChatRequest chat)
        {
            var responseRequest = new ResponseRequest
            {
                conversationName       = chat.conversationName,
                excludedTypes          = chat.excludedTypes,
                exclusiveTypes         = chat.exclusiveTypes,
                requiredProperyMatches = chat.requiredPropertyMatches,
                subjectGoals           = chat.subjectGoals,
                type = chat.type,

                requestTime = DateTime.Now
            };

            return(responseRequest);
        }
        public async Task <ChatResponse> GetResponseAsync(MessageCreateEventArgs e, string chatType, List <string> exclusiveTypes, List <string> excludedTypes, List <string> requiredProperyMatches)
        {
            var chat             = apiUtilities.GetChat(e);
            var conversationName = apiUtilities.GetConversationName(e, chatType);
            var metadata         = apiUtilities.GetMetadata(e);
            var chatRequest      = new ResponseRequest {
                type = chatType, conversationName = conversationName, metadata = metadata, requestTime = DateTime.Now, exclusiveTypes = exclusiveTypes, excludedTypes = excludedTypes, requiredProperyMatches = requiredProperyMatches
            };

            var httpContent = apiUtilities.GetHttpContent(chatRequest);
            var response    = await ApiService.client.PutAsync(ConfigurationService.ApiUrl + "/api/response", httpContent);

            response.EnsureSuccessStatusCode();

            var jsonResponse = await response.Content.ReadAsStringAsync();

            var chatResponse = JsonConvert.DeserializeObject <ChatResponse>(jsonResponse);

            return(chatResponse);
        }
예제 #11
0
        public ChatResponse Put([FromBody] ResponseRequest chat)
        {
            if (_requestValidationService.ValidRequest(chat))
            {
                chat = cleanRequest(chat);
                var response = _queueService.GetResponse(chat);

                response.metadata = chat.metadata;
                return(response);
            }

            dynamic metadata = null;

            if (chat != null && chat.metadata != null)
            {
                metadata = chat.metadata;
            }
            return(new ChatResponse {
                confidence = 0, response = new List <string>(), metadata = metadata
            });
        }
예제 #12
0
        public NetworkConnection(TCPPacketConnection tcpConnection, ResponseRequest responseRequest, PackageAdapter adapter)
        {
            Adapter = adapter;

            TcpPackages     = new SafeStack <PackageInterface>();
            m_openResponses = new SafeList <ResponseRequest>();

            if (responseRequest != null)
            {
                m_openResponses.Add(responseRequest);
            }

            ClientSession = null;

            TcpConnection  = tcpConnection;
            RemoteEndPoint = tcpConnection.Remote;
            OnDisconnect   = TcpConnection.OnDisconnect.CreateRelay(this);

            TcpConnection.DataReceivedEvent  += ReceiveTCP;
            TcpConnection.OnDisconnect.Event += HandleDisconnect;
            TcpConnection.InitializeReceiving();
        }
        async public Task <IActionResult> register([FromBody] SystemUser model)
        {
            ResponseRequest_ = new ResponseRequest();


            var Exists = _context.SystemUsers.Where(r => r.Email == model.Email);

            if (Exists.Count() > 0)
            {
                ResponseRequest_.Status  = 1;
                ResponseRequest_.Message = "هذا الاميل موجود من قبل بالفعل او الرقم المدنى  ";
                return(BadRequest(ResponseRequest_));
            }

            SystemUser user_    = _jwtServices.Register(model);
            var        response = user_;

            ResponseRequest_.Status   = 200;
            ResponseRequest_.Message  = "تم انشاء الحساب بنجاح برجاء الانتظار حتى الموافقه علية";
            ResponseRequest_.Response = response;
            return(Ok(ResponseRequest_));
        }
예제 #14
0
        public async Task <ResponseDto> CreateEntityAsync(ResponseRequest request)
        {
            var entity = _mapper.Map <ResponseRequest, Response>(request);

            entity = await _uow.ResponseRepository.CreateAsync(entity);

            var result = await _uow.SaveAsync();

            if (!result)
            {
                return(null);
            }

            if (entity == null)
            {
                return(null);
            }

            var dto = _mapper.Map <Response, ResponseDto>(entity);

            return(dto);
        }
예제 #15
0
        private ResponseRequest cleanRequest(ResponseRequest chat)
        {
            if (chat.requiredProperyMatches == null)
            {
                chat.requiredProperyMatches = new List <string>();
            }
            if (chat.exclusiveTypes == null)
            {
                chat.exclusiveTypes = new List <string>();
            }
            if (chat.excludedTypes == null)
            {
                chat.excludedTypes = new List <string>();
            }
            if (chat.subjectGoals == null)
            {
                chat.subjectGoals = new List <string>();
            }

            chat.requestTime = DateTime.Now;

            return(chat);
        }
예제 #16
0
 public void IssueResponse(ResponseRequest responseHandler)
 {
     m_openResponses.Add(responseHandler);
 }
예제 #17
0
 public NetworkConnection(TCPPacketConnection tcpConnection, ResponseRequest responseRequest) : this(tcpConnection, responseRequest, new JSONAdapter())
 {
 }
예제 #18
0
 public void NotifyClient(ITcpSocketClient client, ResponseRequest message)
 {
     this.Send(client, message.ToByteArray());
 }
예제 #19
0
        private static void HandleMessage(ITcpSocketClient sender, ResponseRequest e)
        {
            var user = e.Data.ChangeType <User>();

            Console.WriteLine(sender.RemoteAddress + ":" + sender.RemotePort + "\t\tSaid: " + user.ToString());
        }