public void PostMessage(CommMessage msg) { if (channel == null) { Console.Write("\n Cannot send message. The channel is not initial."); return; } // Console.Write("\n Sending message to {0}.Body{1}", msg.Destinaiton,msg.Body); channel.PostMessage(msg); }
/*-----------------------------------------------------------< processing for send thread >--------------------------------------------------------------------*/ void ThreadProc() { tryCount = 0; //count for giving chance to connect while (true) { CommMessage msg = sndBlockingQ.deQ(); if (msg.to != currEndpoint) { currEndpoint = msg.to; //-_creates sender channel for endpoint where msg is going to gets send CreateSendChannel(currEndpoint); //- } while (true) { try { channel.PostMessage(msg); //posts message from one endpoint to sender's endpoint //Console.WriteLine("\n Posted message from {0} to {1}", name, msg.to); tryCount = 0; break; } catch (Exception ex) { Console.Write("\nConnection failed {0}", ex.Message); if (++tryCount < MaxCount) { Thread.Sleep(100); } else { Console.Write("\n{0}", "can't connect\n"); currEndpoint = ""; tryCount = 0; break; } } } if (msg.body == "quit") { break; } } }