public void send(string data) { if (!IsOpened) { logger.LogWarning("An attempt was made to send on a closed data channel."); } else { _sctpStream.send(data); } }
public void testDCEPStreamSend() { Console.WriteLine("---->testDCEPStreamSend string"); StringBuilder rightout = new StringBuilder(); StringBuilder rightLabel = new StringBuilder(); SCTPStreamListener rsl = new ASCTPStreamListenerImpl(rightout); DatagramTransport[] trans = mkMockTransports(); MockAssociationListener listenLeft = new MockAssociationListenerImpl2(); MockAssociationListener listenRight = new MockAssociationListenerImpl3(rightLabel, rsl); ThreadedAssociation instanceLeft = new ThreadedAssociation(trans[0], listenLeft); ThreadedAssociation instanceRight = new ThreadedAssociation(trans[1], listenRight); instanceLeft.associate(); lock (listenLeft) { Monitor.Wait(listenLeft, 2000); Assert.IsTrue(listenLeft.associated); Assert.IsTrue(listenRight.associated); } int id = 10; string label = "test Stream"; SCTPStream s = instanceLeft.mkStream(id, label); lock (rightLabel) { Monitor.Wait(rightLabel, 2000); Assert.AreEqual(rightLabel.ToString(), label); } Assert.IsTrue(typeof(BlockingSCTPStream).IsAssignableFrom(s.GetType())); BlockingSCTPStream bs = (BlockingSCTPStream)s; StringBuilder longTestMessage = new StringBuilder(); for (int i = 0; i < 10000; i++) { longTestMessage.Append(" " + i); } string teststring = longTestMessage.ToString(); Console.WriteLine("-------> string length = " + teststring.Length); Thread st = new Thread(() => { try { s.send(teststring); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }); st.Name = "sender "; st.Start(); lock (rightout) { Monitor.Wait(rightout, 10000); Assert.AreEqual(teststring, rightout.ToString()); } }