Author Topic: EventHandling  (Read 2135 times)

Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
EventHandling
« on: October 19, 2017, 07:13:55 AM »
Hello,
Im tring to do some eventhandling with the voice sdk but no success.

[code] private void button1_Click(object sender, EventArgs e)
        {
            tServerProtocol =
                    new TServerProtocol(
                            new Endpoint(host, 7002));
          tServerProtocol.Received += OnTServerMessageReceived;
            tServerProtocol.Open();
            RequestRegisterAddress requestRegisterAddress = RequestRegisterAddress.Create("1234",RegisterMode.ModeShare,ControlMode.RegisterDefault,AddressType.DN);
            tServerProtocol.Request(requestRegisterAddress);
        }
        void OnTServerMessageReceived(object sender, EventArgs e)
        {
            IMessage message = ((MessageEventArgs)e).Message;
            switch (message.Id)
            {
                case EventRegistered.MessageId:
                    MessageBox.Show("Registered");
                    break;
                case EventUnregistered.MessageId:
                    break;
            }         
        }[/code]

My method  void OnTServerMessageReceived is never hit?
am Im doing something wrong here? As I follow the Genesys documentation.

Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Re: EventHandling
« Reply #1 on: October 19, 2017, 08:49:46 AM »
I foudn that when using below code I get the Event.

[code]tServerProtocol.Send((RequestRegisterAddress.Create("1234", RegisterMode.ModeShare, ControlMode.RegisterDefault, AddressType.DN)));[/code]

My question now is: If for an example a call is received by this dn, will I get also the event?

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: EventHandling
« Reply #2 on: October 19, 2017, 01:43:24 PM »
[quote author=carpio link=topic=10696.msg48553#msg48553 date=1508402986]
[code]tServerProtocol.Send((RequestRegisterAddress.Create("1234", RegisterMode.ModeShare, ControlMode.RegisterDefault, AddressType.DN)));[/code]

My question now is: If for an example a call is received by this dn, will I get also the event?
[/quote]
Yes. You will get EventRinging upon hitting the DN and EventEstablished upon answering the call. In your case, you have to add those Message.ID on your "switch" statement to handle those events on your code.