void ClearAllListeners_inLock(out CommonRfcommStream[] all) { System.Collections.ICollection all0 = m_listening.Values; all = new CommonRfcommStream[all0.Count]; all0.CopyTo(all, 0); m_listening.Clear(); }
//---- protected override CommonRfcommStream GetNewPort() { CommonRfcommStream port = WidcommL2CapClient.GetWidcommL2CapStreamWithThisIf( m_factory, _rfCommIf__tmp); return(port); }
internal WidcommL2CapClient(WidcommBluetoothFactoryBase factory, CommonRfcommStream conn) : base(factory, conn) { Debug.Assert(factory != null, "factory must not be null; is used by GetRemoteMachineName etc."); m_factory = factory; m_connRef = (WidcommL2CapStream)conn; // CAST!! }
internal static void Assert_IsConnected(IsConnectedState expected, CommonRfcommStream conn, IBluetoothClient cli, string descr) { switch (expected) { case IsConnectedState.Closed: Assert.IsFalse(conn.LiveConnected, "conn.LiveConnected " + descr); Assert.IsFalse(conn.Connected, "conn.Connected " + descr); Assert.IsFalse(cli.Connected, "cli.Connected " + descr); break; case IsConnectedState.Connected: Assert.IsTrue(conn.LiveConnected, "conn.LiveConnected " + descr); Assert.IsTrue(conn.Connected, "conn.Connected " + descr); Assert.IsTrue(cli.Connected, "cli.Connected " + descr); break; case IsConnectedState.RemoteCloseAndBeforeAnyIOMethod: Assert.IsFalse(conn.LiveConnected, "conn.LiveConnected " + descr); // These two aren't strict through........... Assert.IsTrue(conn.Connected, "conn.Connected " + descr); Assert.IsTrue(cli.Connected, "cli.Connected " + descr); break; default: break; } }
protected override IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream acceptedStream) { #if NETCF throw new NotImplementedException("The method or operation is not implemented."); #else return(new NullBtCli(this, acceptedStream)); #endif }
public IBluetoothClient EndAcceptBluetoothClient(IAsyncResult asyncResult) { AsyncResult_BABc ar2 = (AsyncResult_BABc)asyncResult; CommonRfcommStream strm = ar2.EndInvoke(); IBluetoothClient cli0 = GetBluetoothClientForListener(strm); Debug.Assert(cli0.Connected, "cli0.Connected"); return(cli0); }
readonly CommonRfcommStream m_childWrs; // WRS required for DataAvailable property. internal RfcommDecoratorNetworkStream(CommonRfcommStream childWrs) : base(childWrs) { if (!childWrs.Connected) // Although the base constructor will have checked already. { throw new ArgumentException("Child stream must be connected."); } m_childWrs = childWrs; }
void PortAcceptCallback(IAsyncResult ar) { AsyncResult_BABc arSac; // Call SetAsCompleted outside the lock. Exception exSac; AsyncResultNoResult ar2 = (AsyncResultNoResult)ar; CommonRfcommStream port = (CommonRfcommStream)ar2.AsyncState; lock (m_key) { try { port.EndAccept(ar2); exSac = null; } catch (Exception ex) { if (IsDisposed) { Debug.WriteLine("INFO PortAccepted was an error (Stopped: true): " + ex.Message); } else { Debug.WriteLine("PortAccepted was an error: " + ex.ToString()); } if (IsDisposed) { return; } exSac = ex; } bool found = m_listening.Remove(port); Debug.Assert(found, "NOT found"); if (m_callers.Count > 0) { // Release one Accept immediately Debug.Assert(m_accepted.Count == 0, "Why clients waiting when also pending accepted!?!"); arSac = m_callers.Dequeue(); Debug.WriteLine("PortAccepted Dequeued a caller"); } else { // Queue the new port for later accept call if (exSac != null) // DEBUG { } m_accepted.Enqueue(new AcceptedPort(port, exSac)); arSac = null; Debug.WriteLine("PortAccepted Enqueued"); } StartEnoughNewListenerPort_inLock(); }// lock // Raise events if any. var args = new RaiseAcceptParams { arSac = arSac, exSac = exSac, port = port }; ThreadPool.QueueUserWorkItem(RaiseAccept, args); }
//public abstract IBluetoothClient tGetBluetoothClientForListener(CommonRfcommStream acceptedStrm); protected sealed override IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream acceptedStrm) { //return tGetBluetoothClientForListener(acceptedStrm); var mockC = new Mock <IBluetoothClient>(); var hackAlwaysSayConnected = true; mockC.SetupGet(px => px.Connected) .Returns(hackAlwaysSayConnected); return(mockC.Object); }
public AcceptedPort(CommonRfcommStream port, Exception error) { if (port == null) { throw new ArgumentNullException("port"); } _port = port; _error = error; if (_error != null) // COVERAGE { } }
void _StartOneNewListenerPort_inLock() { //Console.WriteLine("Starting a new listening port..."); CommonRfcommStream port = GetNewPort(); m_listening.Add(port, port); IAsyncResult ar = port.BeginAccept(m_liveLocalEP, null, PortAcceptCallback, port); Debug.Assert(ar is AsyncResultNoResult, "assert type"); Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "StartOneNewListenerPort {0}.", port.DebugId)); }
protected virtual IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream strm) { IBluetoothClient cli0 = m_factory.DoGetBluetoothClientForListener(strm); return(cli0); }
internal NullBtCli(NullBluetoothFactory fcty, CommonRfcommStream conn) : base(fcty, conn) { }
//---- protected override CommonRfcommStream GetNewPort() { CommonRfcommStream port = m_factory.GetWidcommRfcommStreamWithoutRfcommIf(); return(port); }
protected override IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream acceptedStream) { return(new WidcommBluetoothClient((WidcommRfcommStreamBase)acceptedStream, this)); }
public IBluetoothClient DoGetBluetoothClientForListener(CommonRfcommStream acceptedStream) { return(GetBluetoothClientForListener(acceptedStream)); }
protected abstract IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream acceptedStrm);
//---- Force **no** mocking ---- protected sealed override IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream strm) { return(base.GetBluetoothClientForListener(strm)); }
//---- internal BluetoothRfcommStreamConnector(IUsesBluetoothConnectorImplementsServiceLookup parent, CommonRfcommStream conn) : base(parent) { m_conn = conn; }
protected override IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream acceptedStrm) { throw new NotSupportedException(); }
internal BluetopiaClient(BluetopiaFactory fcty, CommonRfcommStream conn) : base(fcty, conn) { Debug.Assert(fcty != null, "fcty NULL!"); _factory = fcty; }
internal static IBluetoothClient factory_DoGetBluetoothClientForListener( WidcommBluetoothFactoryBase fcty, CommonRfcommStream strm) { return(new WidcommL2CapClient(fcty, strm)); }
protected override IBluetoothClient GetBluetoothClientForListener(CommonRfcommStream acceptedStrm) { return(new BluetopiaClient(this, acceptedStrm)); }
protected CommonBluetoothClient(BluetoothFactory factory, CommonRfcommStream conn) { Debug.Assert(factory != null, "NULL factory"); _fcty = factory; m_conn = new BluetoothRfcommStreamConnector(this, conn); }
protected override IBluetoothClient GetBluetoothClientForListener( CommonRfcommStream strm) { return(WidcommL2CapClient.factory_DoGetBluetoothClientForListener( m_factory, strm)); }