troubleshooting Question

pc-pc using RTC in C#

Avatar of Xmdy
Xmdy asked on
1 Comment1 Solution208 ViewsLast Modified:
I'm trying to create a simple client application for pc-pc communication using RTC in C#. I'm new to this kind of programming but wanna learn it, so i'll explain as easy understandable as possible.
I am using a Form1 where i initialize my rtc client _rtc.Initialize(). It contains methods for: clicking 2 buttons: 1 to listen for incomming connections and 2 to attempt a connection, as well as the ones for event notification, for media events and for session state change (RTC_IRTCEventNotification_Event_Event(etc..)  OnIRTCMediaEvent  OnIRTCSessionStateChangeEvent)

-my button1_Click method contains

_rtc.SetPreferredMediaTypes(receiveAudio | sendAudio | receiveVideo | sendVideo, true);
            _rtc.EventFilter = media | messaging;
            _rtc.IRTCEventNotification_Event_Event += new IRTCEventNotification_EventEventHandler(RTC_IRTCEventNotification_Event_Event);
            _rtc.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH;

-my button2_Click contains

_session = _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_PC_TO_PC, null, null, 0);            
            _session.AddParticipant(adresaIP, nume);

I wrote here only the main code lines and skipped the ones where i get my parameters from.
I want the application to work as a server and a client or, not as a real server, only for the other client so the two pc's can communicate. I was expecting when i press my 1st button on one pc, after, press my 2nd button on other pc, the 2nd pc to attempt a connection to the 1st; I'm sure at some point some connection attempted because i heard _rtc.PlayRing from OnIRTCSessionStateChangeEvent(..) but i couldn't get my code back to that old stage.
Am i missing some hardware selection with a method i don't know about? or am i missing some code? or i got the wrong idea of how to make this work?
I didn't write here the contents of the 3 methods for event handling, media handling and state change but i think they are ok. If i should write more of my code here just tell me. Any answer would be appreciated, thanks.
I managed to make the application to answer an incoming session all the time by setting the _rtc.EventFilter = 0x01FFFFFF;
However, i hit other problem, can't send a message. My 1st client is listening:
_rtc.EventFilter = 0x01FFFFFF;
_rtc.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH;
_rtc.IRTCEventNotification_Event_Event += new IRTCEventNotification_EventEventHandler(RTC_IRTCEventNotification_Event_Event);

while my 2nd client is connecting:
_session = _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_PC_TO_PC, null, null, 0);
_session.AddParticipant(adresaIP, nume);

the 1st client answers the incoming session using _session.Answer(); but _session is still null after _sessionAnswer();. It should be so? The problem comes when i try sending a message after the session is answered and i get a NullRefereneException for the _session.SendMessage(msgHeader, msg, 0); line. Is the session not created? Should i create the session on my 1st listening client? adding the line in 1st client listening
_session = _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_PC_TO_PC, null, null, 0);
sends me into another exception for the same _session.SendMessage.. line with value 0x80EE0029 which means "The client is already initialized." so i think the session should be created on answer not need to be added before.
Where am i wrong?

I noticed that the listening pc is actually never answering a call, so whole problem might resume to _session.Answer(); which is never working. Anyone know any issue with answering an incoming pc-pc call? please let me know, ty
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros