public void OnReconnectTry() { if (!this.connectCalled || this.disconnectCalled) { StopPolling(); return; } I_XmlBlasterAccess old = this.delegateXb; if (old != null) { this.delegateXb = null; old.LeaveServer(); } if (this.gprsManager != null) { this.gprsManager.Connect(false); } this.delegateXb = CreateNative(); ConnectReturnQos qr = Connect(this.connectQosStr, this.callback); if (qr == null) { throw new XmlBlasterException("communication.noConnection", "we are polling for the server"); } StopPolling(); StartPinging(); //OnLogging(XmlBlasterLogLevel.WARN, "XmlBlasterAccess", "No connection to server: " + e.ToString()); }
public ConnectReturnQos Connect(string qos, I_Callback listener) { try { this.CheckValid(); this.connectQosStr = qos; this.callback = listener; this.connectCalled = true; // before connect() this.disconnectCalled = false; this.connectReturnQos = this.delegateXb.Connect(qos, listener); this.xbPoller.Stop(); this.xbPinger.Start(); return(this.connectReturnQos); } catch (Exception e) { if (this.pollOnInitialConnectFail) { StartPolling(); return(null); } else { throw e; } } }
public Hello(string[] argv) { I_XmlBlasterAccess nc = XmlBlasterAccessFactory.CreateInstance(); nc.Initialize(argv); nc.Initialize(new Hashtable()); nc.RegisterConnectionListener(this); string connectQos = String.Format( "<qos>\n" + " <securityService type='htpasswd' version='1.0'>\n" + " <![CDATA[\n" + " <user>fritz</user>\n" + " <passwd>secret</passwd>\n" + " ]]>\n" + " </securityService>\n" + " <queue relating='callback' maxEntries='50000' maxEntriesCache='10000'>\n" + " <callback type='SOCKET' sessionId='{0}'>\n" + " </callback>\n" + " </queue>\n" + "</qos>", callbackSessionId); //" socket://{1}:{2}"+ Console.WriteLine("Connecting with:" + connectQos); I_Callback callback = this; ConnectReturnQos qos = nc.Connect(connectQos, callback); Console.WriteLine("Connected." + qos.GetSessionName()); for (int i = 0; i < 5; i++) { SubscribeReturnQos srq = nc.Subscribe("<key oid='Hello'/>", "<qos/>"); Console.WriteLine("subscribe() returned " + srq.GetSubscriptionId()); //nc.publish("<key oid='Hello'/>", "HIII", "<qos/>"); PublishReturnQos prq = nc.Publish("<key oid='C#C#C#'/>", "HIIIHAAAA", "<qos/>"); Console.WriteLine("publish() returned " + prq.GetKeyOid()); prq = nc.Publish("<key oid='C#C#C#'/>", "HIIIHOOO", "<qos/>"); Console.WriteLine("publish() returned " + prq.GetKeyOid()); MsgUnitGet[] msgs = nc.Get("<key oid='C#C#C#'/>", "<qos><history numEntries='6'/></qos>"); Console.WriteLine("get() returned " + msgs.Length + " messages"); string p = nc.Ping("<qos/>"); Console.WriteLine("ping() returned " + p); bool b = nc.IsConnected(); Console.WriteLine("isConnected() returned " + b); UnSubscribeReturnQos[] urq = nc.UnSubscribe("<key oid='Hello'/>", "<qos/>"); Console.WriteLine("unSubscribe() returned " + urq[0].GetSubscriptionId()); EraseReturnQos[] erq = nc.Erase("<key oid='C#C#C#'/>", "<qos/>"); Console.WriteLine("erase() returned " + erq[0].GetKeyOid()); Console.WriteLine("\nHit a key " + i); Console.ReadLine(); } bool drq = nc.Disconnect("<qos/>"); Console.WriteLine("disconnect() returned " + drq); Console.WriteLine("DONE"); }