public void Receive(object source, ElapsedEventArgs e)
        {
            if (source is SessionController)
            {
                string senderAddress = currentSession.WindowsIdentityName;

                using (SessionServiceReference.SessionServiceClient service = new SessionServiceReference.SessionServiceClient())
                {
                    SessionServiceReference.Message[] listMess = service.GetMessage(senderAddress);

                    foreach (SessionServiceReference.Message mess in listMess)
                    {
                        Message newMess = new Message
                        {
                            Content = mess.Content,
                            Instant = mess.Instant,
                            ReceiverAddress = mess.ReceiverAddress,
                            SenderAddress = mess.SenderAddress
                        };

                        (source as SessionController).OnMessageReceived(newMess);
                    }
                }
            }
        }
 public void SendConsole(Message message)
 {
     using (SessionServiceReference.SessionServiceClient client = new SessionServiceReference.SessionServiceClient())
     {
         client.SendConsole(message);
     }
 }
 /// <summary>
 /// fonction d'envoi d'un message
 /// </summary>
 /// <param name="message">le message à envoyer</param>
 public void send(Message message)
 {
     System.Threading.Thread.Sleep(5000);
     // S'il y a des abonnés on lance l'evenement
     if (MessageReceived != null)
         MessageReceived(this, new MessageEventArgs(message));
 }
 public void OnMessageReceived(Message messageData)
 {
     if (MessageReceived != null)
     {
         MessageReceived(this, new MessageEventArgs(messageData));
     }
 }
 public void Send(Message message)
 {
     //identique avec session au lieu de contact
     using (SessionServiceReference.SessionServiceClient service = new SessionServiceReference.SessionServiceClient())
     {
         SessionServiceReference.Message mess = new SessionServiceReference.Message();
         mess.ReceiverAddress = message.ReceiverAddress;
         mess.SenderAddress = message.SenderAddress;
         mess.Content = message.Content;
         mess.Instant = message.Instant;
         service.SendMessage(mess);
     }
 }
 public void Send(Message message)
 {
     // Simulate a conference by waiting 5 seconds prior to sending a response
     System.Threading.Thread.Sleep(5000);
     Message echo = new Message()
     {
         SenderAddress = message.ReceiverAddress,
         ReceiverAddress = message.SenderAddress,
         Content = string.Concat("Echo: ", message.Content),
         Instant = DateTime.Now
     };
     OnMessageReceived(echo);
 }
        public void Send(Message message)
        {
            // Simulate a conference by waiting 5 seconds prior to sending a response
            /*System.Threading.Thread.Sleep(5000);
            Message echo = new Message()
            {
                SenderAddress = message.ReceiverAddress,
                ReceiverAddress = message.SenderAddress,
                Content = string.Concat("Echo: ", message.Content),
                Instant = DateTime.Now
            };
            OnMessageReceived(echo);*/

            //appel la méthode send du webservice
            ISessionManager sessionManager = currentSessionManager;
            currentSessionManager.Send(message);
        }
Beispiel #8
0
 public MessageEventArgs(Message message)
 {
     _message = message;
 }
 public MessageEventArgs(Message messageData)
 {
     this.MessageData = messageData;
 }
Beispiel #10
0
 private static void Send(Message m)
 {
     MessagingContext.Current.MessagingSessionController.SendConsole(m);
     Console.SetCursorPosition(0, Console.CursorTop);
     if (MessagingContext.Current.MessagingSessionController.GetPresence(receiverAddress) != 0)
     {
         Console.WriteLine("Message sent.\n");
     }
     else
     {
         Console.WriteLine("Message in Recipient Queue.\n");
     }
     Console.Write("> ");
 }
Beispiel #11
0
        private static void RunConsole()
        {
            Message m;
            Console.WriteLine("Conversation between you and " + receiverAddress + " started.");
            while (1 == 1)
            {
                if (bgwInitializer.IsBusy)
                {
                    Console.WriteLine("Session is being initialized, please wait...");
                    while (bgwInitializer.IsBusy)
                    { }
                }
                else
                {
                    Console.Write("> ");
                    string input = Console.ReadLine();
                    Console.SetCursorPosition(Console.CursorLeft, Console.CursorTop - 1);
                    Console.Write("You [" + DateTime.Now + "] :");
                    for (int i = Console.CursorLeft; i < Console.WindowWidth; ++i)
                        Console.Write(" ");
                    Console.WriteLine("\n> " + input);
                    if (string.Compare(input, "BYE", false) == 0)
                    {
                        MessagingContext.Current.MessagingSessionController.Bye(sessionId);
                        break;
                    }
                    else if (string.Compare(input, "ADD") == 0)
                    {
                        Console.WriteLine("Entrez l'adresse du nouveau contact :");
                        string Address = Console.ReadLine();
                        Console.WriteLine("Entrez son nom :");
                        string Name = Console.ReadLine();
                        contacts.Contacts.Rows.Add(Address, Name);
                        Console.Clear();
                        Console.WriteLine("Contact added");
                    }
                    else if (string.Compare(input, "CHANGE") == 0)
                    {
                        AnalyzeArgument();
                        Console.WriteLine("Conversation between you and " + receiverAddress + " started.");
                    }
                    else if (string.Compare(input, "DELETE") == 0)
                    {
                        Console.WriteLine("Choose the contact you want to delete by typing his index :");
                        for (int i = 0; i < contacts.Contacts.Rows.Count; ++i)
                        {
                            Console.WriteLine(i + " -> " + contacts.Contacts.Rows[i][0] + " (" + statusText[MessagingContext.Current.MessagingSessionController.GetPresence(contacts.Contacts.Rows[i][0].ToString())] + ")");
                        }
                        int indice = -1;
                        while (!int.TryParse(Console.ReadLine(), out indice) || indice < 0 || indice >= contacts.Contacts.Rows.Count)
                        {
                            Console.WriteLine("Enter an integer please.");
                        }
                        contacts.Contacts.Rows.RemoveAt(indice);
                        AnalyzeArgument();
                        Console.WriteLine("Conversation between you and " + receiverAddress + " started.");
                    }
                    else if (string.Compare(input, "SAVE") == 0)
                    {
                        MessagingContext.Current.ContactsManager.Save(contacts);
                        Console.Clear();
                        Console.WriteLine("Contact list saved");
                    }
                    else if (input.Equals("")) { }
                    else
                    {
                        string sanitizedText = Sanitizer.Sanitize(Sanitizer.NeutralizeUrl(input));
                        string encodedText = Base64Encoder.Encode(sanitizedText);
                        string decodedText = Base64Encoder.Decode(encodedText);

                        m = new Message() { SenderAddress = MessagingContext.Current.SenderAddress, ReceiverAddress = receiverAddress, Instant = DateTime.Now, Content = input };

                        bgwSender.RunWorkerAsync(m);
                    }
                }
            }
        }