Ejemplo n.º 1
0
 /// <summary>
 /// The front-end calls the SendMessage method in order to broadcast a message to our friends
 /// </summary>
 /// <param name="text"></param>
 public void SendMessage(string text)
 {
     if (text.StartsWith("setname:", StringComparison.OrdinalIgnoreCase))
     {
         _myUserName = text.Substring("setname:".Length).Trim();
         _displayMessageDelegate(new CompositeType("Event", "Setting your name to " + _myUserName));
     }
     else
     {
         // In order to send a message, we call our friends' DisplayMessage method
         _channel.DisplayMessage(new CompositeType(_myUserName, text));
     }
 }
Ejemplo n.º 2
0
        private void StartService()
        {
            try
            {
                host = new ServiceHost(this);
                host.Open();
                channelFactory = new ChannelFactory <IP2PService>("ChatEndpoint");
                _channel       = channelFactory.CreateChannel();

                // Information to send to the channel
                _channel.DisplayMessage(new CompositeType("Event", _myUserName + " has entered the conversation."));

                // Information to display locally
                _displayMessageDelegate(new CompositeType("Info", "To change your name, type setname: NEW_NAME"));
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
            }
        }
Ejemplo n.º 3
0
        private void StartService()
        {
            try
            {
                host = new ServiceHost(this);
                host.Open();
                channelFactory = new ChannelFactory<IP2PService>("ChatEndpoint");
                _channel = channelFactory.CreateChannel();

                // Information to send to the channel
                _channel.DisplayMessage(new CompositeType("Event", _myUserName + " has entered the conversation."));

                // Information to display locally
                _displayMessageDelegate(new CompositeType("Info", "To change your name, type setname: NEW_NAME"));
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
            }
        }