/// <summary> /// Loads the ORTC factory /// </summary> /// <returns></returns> private bool ORTCLoadFactory() { try { // Load factory var api = new Ibt.Ortc.Api.Ortc("Plugins"); IOrtcFactory factory = api.LoadOrtcFactory("IbtRealTimeSJ"); if (factory != null) { // Construct object ortcClient = factory.CreateClient(); if (ortcClient != null) { ortcClient.Id = "RTCH"; // Handlers ortcClient.OnConnected += new OnConnectedDelegate(ortc_OnConnected); ortcClient.OnDisconnected += new OnDisconnectedDelegate(ortc_OnDisconnected); ortcClient.OnException += (sender, error) => { Log(error.ToString()); }; return(true); } } else { Log("Factory is null"); } } catch (Exception ex) { Log(ex.Message); } if (ortcClient == null) { Log("ORTC object is null"); } return(false); }
private void LoadFactory() { try { // Load factory var api = new Api.Ortc("Plugins"); IOrtcFactory factory = api.LoadOrtcFactory("IbtRealTimeSJ"); if (factory != null) { // Construct object _ortc = factory.CreateClient(); if (_ortc != null) { _ortc.Id = "dot_net_client"; //_ortc.ConnectionTimeout = 10000; // Handlers _ortc.OnConnected += new OnConnectedDelegate(ortc_OnConnected); _ortc.OnDisconnected += new OnDisconnectedDelegate(ortc_OnDisconnected); _ortc.OnReconnecting += new OnReconnectingDelegate(ortc_OnReconnecting); _ortc.OnReconnected += new OnReconnectedDelegate(ortc_OnReconnected); _ortc.OnSubscribed += new OnSubscribedDelegate(ortc_OnSubscribed); _ortc.OnUnsubscribed += new OnUnsubscribedDelegate(ortc_OnUnsubscribed); _ortc.OnException += new OnExceptionDelegate(ortc_OnException); } } else { Log("Factory is null"); } } catch (Exception ex) { Log(ex.Message); } if (_ortc == null) { Log("ORTC object is null"); } }
public static void Main(string[] args) { Console.Write("Enter your app key: "); var appKey = Console.ReadLine(); Console.WriteLine(); Console.WriteLine($"Using app key {appKey}"); var api = new Ibt.Ortc.Api.Ortc(); IOrtcFactory factory = api.LoadOrtcFactory(""); var client = factory.CreateClient(); client.ClusterUrl = "http://ortc-developers.realtime.co/server/2.1/"; client.ConnectionMetadata = "this can be anything?"; client.OnConnected += (object sender) => { Console.WriteLine("Connected to realtime.co"); Console.WriteLine("Subscribing to testChannel"); client.Subscribe( "testChannel", true, (s, channel, message) => { Console.WriteLine($"message recieved on testChannel: {message}"); }); }; client.OnDisconnected += (object sender) => { Console.WriteLine("Disconnected from realtime.co"); }; client.OnException += (object sender, Exception ex) => { Console.WriteLine(ex); }; client.Connect(appKey, "myToken"); var waitHandle = new ManualResetEvent(false); Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => { waitHandle.Set(); }; waitHandle.WaitOne(); Console.WriteLine("Done"); }
private void factory_start() { try { api = new Ortc(); IOrtcFactory fact = api.LoadOrtcFactory("test"); if (fact != null) { _ortc = fact.CreateClient(); if (_ortc != null) { _ortc.Id = "dot_net_client"; // set OrtcCLient properties here if you wish _ortc.OnConnected += new OnConnectedDelegate(ortc_OnConnected); _ortc.OnDisconnected += new OnDisconnectedDelegate(ortc_OnDisconnected); _ortc.OnReconnecting += new OnReconnectingDelegate(ortc_OnReconnecting); _ortc.OnReconnected += new OnReconnectedDelegate(ortc_OnReconnected); _ortc.OnSubscribed += new OnSubscribedDelegate(ortc_OnSubscribed); _ortc.OnUnsubscribed += new OnUnsubscribedDelegate(ortc_OnUnsubscribed); _ortc.OnException += new OnExceptionDelegate(ortc_OnException); Console.WriteLine("Factory_start succesfull"); } } else { Console.WriteLine("Failure for fact"); } } catch { Console.WriteLine("Error"); } if (_ortc == null) { Console.WriteLine("Null ortc"); // cw TAB -- console write } }