Esempio n. 1
0
 public AuthServerChatMessage(string p_user_name, ChatMessageForServer p_chat_message)
 {
     user_name    = p_user_name;
     chat_message = p_chat_message;
 }
 public void Receive(MessageFromServerWorkerQueueObject p_global_message_to_server_from_queue)
 {
     if (thread_is_logged_in(p_global_message_to_server_from_queue.Get_thread_id))
     {
         string user_name = get_a_thread_user_name(p_global_message_to_server_from_queue.Get_thread_id);
         if (user_name == null)
         {
             return;
         }
         if (p_global_message_to_server_from_queue.Get_message_from_worker.Get_type_of_message_from_server_worker == TypeOfMessageFromServerWorker.FinalMessageForServer)
         {
             FinalMessageForServer user_message = null;
             try
             {
                 user_message = (FinalMessageForServer)p_global_message_to_server_from_queue.Get_message_from_worker.Get_message_from_server_worker_object;
             }
             catch (Exception)
             {
                 return;
             }
             if (user_message.Get_message_type == TypeOfMessage.Chat)
             {
                 ChatMessageForServer user_chat_message = null;
                 try
                 {
                     user_chat_message = ((ChatMessageForServer)user_message.Get_message_object);
                     chat_receive_message(new AuthServerChatMessage(user_name, user_chat_message));
                     return;
                 }
                 catch (Exception)
                 {
                     return;
                 }
             }
             else if (user_message.Get_message_type == TypeOfMessage.Dialog)
             {
                 DialogMessageForServer user_dialog_message = null;
                 try
                 {
                     user_dialog_message = (DialogMessageForServer)user_message.Get_message_object;
                     dialog_receive_message(new AuthServerDialogMessage(user_dialog_message, user_name));
                     return;
                 }
                 catch (Exception)
                 {
                     return;
                 }
             }
         }
         else if (p_global_message_to_server_from_queue.Get_message_from_worker.Get_type_of_message_from_server_worker == TypeOfMessageFromServerWorker.MakeOfflineMessage)
         {
             List <FinalMessageForServer> make_offline_messages = new List <FinalMessageForServer>();
             try
             {
                 make_offline_messages = (List <FinalMessageForServer>)p_global_message_to_server_from_queue.Get_message_from_worker.Get_message_from_server_worker_object;
             }
             catch (Exception)
             {
                 return;
             }
             make_messages_offline(user_name, make_offline_messages);
             return;
         }
         else if (p_global_message_to_server_from_queue.Get_message_from_worker.Get_type_of_message_from_server_worker == TypeOfMessageFromServerWorker.ofllienRequestMessage)
         {
             offline_user(user_name);
             return;
         }
     }
     else if (!thread_is_logged_in(p_global_message_to_server_from_queue.Get_thread_id))
     {
         if (!is_there_unauth_worker_thread(p_global_message_to_server_from_queue.Get_thread_id))
         {
             register_a_thread_request(p_global_message_to_server_from_queue.Get_thread_id);
         }
         if (p_global_message_to_server_from_queue.Get_message_from_worker.Get_type_of_message_from_server_worker == TypeOfMessageFromServerWorker.FinalMessageForServer)
         {
             FinalMessageForServer user_message = null;
             try
             {
                 user_message = ((FinalMessageForServer)p_global_message_to_server_from_queue.Get_message_from_worker.Get_message_from_server_worker_object);
             }
             catch (Exception)
             {
                 return;
             }
             if (user_message.Get_message_type == TypeOfMessage.Dialog)
             {
                 DialogMessageForServer user_dialog_message = null;
                 try
                 {
                     user_dialog_message = (DialogMessageForServer)user_message.Get_message_object;
                 }
                 catch (Exception)
                 {
                     return;
                 }
                 dialog_receive_message(new UnAuthServerDialogMessage(user_dialog_message, p_global_message_to_server_from_queue.Get_thread_id));
                 return;
             }
         }
         if (p_global_message_to_server_from_queue.Get_message_from_worker.Get_type_of_message_from_server_worker == TypeOfMessageFromServerWorker.ofllienRequestMessage)
         {
             thread_remove_works(p_global_message_to_server_from_queue.Get_thread_id);
         }
     }
 }