/// ---------------------------------------------------------------------------------------- /// RETAIL /// ---------------------------------------------------------------------------------------- public RbrResult InitRetailSession(ISession pSession, out ScriptInfo pScriptInfo) { T.LogDebug(string.Format(">> {0}, ANI={1}, OrigIP={2}, AccessNumber={3}", pSession.Id, pSession.ANI, pSession.OrigIPAddress, pSession.AccessNumber)); //-- create default ScriptInfo: pScriptInfo = new ScriptInfo(); pScriptInfo.RbrRoot = AppConstants.RbrRoot; pScriptInfo.ScriptLanguage = ScriptLanguage.English; pScriptInfo.PinLength = 9; pScriptInfo.ScriptType = ScriptType.PhoneCard; T.LogDebug(string.Format("<< ScriptInfo={0}", pScriptInfo)); return(RbrResult.Success); }
//-------------------------------------- Private -------------------------------------------------- private bool dispatcher(string pCmd) { try { // Create a command factory and call it to create correct CommandMessage instance: ICommand _cmd = commandFactory.GetInstance(UdpMessageParser.GetCommandNameAndVersion(pCmd)); _cmd.Sequence = UdpMessageParser.GetSequence(pCmd); _cmd.Parameters = UdpMessageParser.GetInParameters(pCmd); //Process command: _cmd.Execute(); return(_cmd.Result); } catch (Exception _ex) { T.LogCritical("Exception: " + Utils.GetFullExceptionInfo(_ex)); } return(false); }
public void LogOutput(SoapMessage pMessage) { try { //-- First reset newStream position newStream.Position = 0; StringWriter _sw = new StringWriter(); copy(newStream, _sw); string _soapString = (pMessage is SoapServerMessage) ? "SoapResponse:" : "SoapRequest:"; T.LogDebug(" " + _soapString + "\r\n" + _sw.GetStringBuilder().ToString()); //-- Last, reset newStreamPosition and copy to oldStream newStream.Position = 0; copy(newStream, oldStream); } catch (Exception ex) { T.LogCritical(string.Format("Exception\r\n{0}", ex)); } }
//------------------------------ Private ---------------------------------------- private void send(string pToGroup, string pMessage, bool pIsSelfDiscard) { SpreadMessage _spreadMsg = new SpreadMessage(); _spreadMsg.IsAgreed = true; // _spreadMsg.IsSafe = true; _spreadMsg.IsSelfDiscard = pIsSelfDiscard; _spreadMsg.AddGroup(pToGroup); _spreadMsg.Data = System.Text.Encoding.ASCII.GetBytes(pMessage); // Send msg and wait for response try { connection.Multicast(_spreadMsg); // if ( ! pIsSelfDiscard) { // SyncLock.Wait(); // } } catch (Exception _ex) { T.LogStatus("Multicast Exception: " + _ex); throw; } }
private void connect(string pGroup) { // Establish the spread connection. try { connection = new SpreadConnection(); connection.Connect(address, port, userName, false, true); } catch (SpreadException _ex) { T.LogCritical("There was an error connecting to the daemon: " + _ex); Environment.Exit(1); } catch (Exception _ex) { T.LogCritical("Can't find the daemon " + address + " Exception: " + _ex); Environment.Exit(1); } // start receiving thread rt = new RecThread(connection); Thread rtt = new Thread(new ThreadStart(rt.Run)); rtt.Start(); // start listener regularMessageHandler = new SpreadConnection.MessageHandler(regularMsgReceived); connection.OnRegularMessage += regularMessageHandler; membershipMessageHandler += new SpreadConnection.MessageHandler(membershipMsgReceived); connection.OnMembershipMessage += membershipMessageHandler; lock (rt) { rt.threadSuspended = true; } listening = true; T.LogStatus("Listening: " + listening); // join group group = new SpreadGroup(); group.Join(connection, pGroup); T.LogStatus("Joined: " + group + "."); }
public RbrResult AuthorizeRetail(ISession pSession, out string pOutDestNumber, out string pCalledIpAndPort, out short pCustomerAcctId, out short pCarrierAcctId, out int pCustomerRouteId, out int pCarrierRouteId, out int pTimeLimit, out int pPromptTimeLimit) { pOutDestNumber = pSession.DestNumber; //it may be cleared of inbound prefix and overwritten by outbound Prefix, IntlDialCode pCalledIpAndPort = AppConstants.TestTermIP; pCustomerAcctId = 1000; pCarrierAcctId = 1001; pCustomerRouteId = 1234; pCarrierRouteId = 4321; pTimeLimit = 30; pPromptTimeLimit = 30; T.LogDebug(string.Format(">> {0}, OrigIP={1}, ANI={2}, AccessNumber={3}, Card_number={4}, DestNumber={5}", pSession.Id, pSession.OrigIPAddress, pSession.ANI, pSession.AccessNumber, pSession.CardNumber, pSession.DestNumber)); return(RbrResult.Success); }
private void disconnect() { // leave group if (group != null) { group.Leave(); T.LogDebug("Left " + group + "."); } else { T.LogDebug("No group to leave."); } // stop listener if (listening) { if (regularMessageHandler != null) { connection.OnRegularMessage -= regularMessageHandler; } if (membershipMessageHandler != null) { connection.OnMembershipMessage -= membershipMessageHandler; } if (rt.threadSuspended) { lock (rt) { Monitor.Pulse(rt); rt.threadSuspended = false; } } } // Disconnect. connection.Disconnect(); }
public void SetRetailAcctNotInUse(ISession pSession) { T.LogDebug(string.Format(">> {0}, ANI={1}, DNIS={2}, Card_number={3}", pSession.Id, pSession.ANI, pSession.AccessNumber, pSession.CardNumber)); }
private void display(SpreadMessage msg) { try { if (msg.IsRegular) { T.LogDebug("Received a "); if (msg.IsUnreliable) { T.LogDebug("UNRELIABLE"); } else if (msg.IsReliable) { T.LogDebug("RELIABLE"); } else if (msg.IsFifo) { T.LogDebug("FIFO"); } else if (msg.IsCausal) { T.LogDebug("CAUSAL"); } else if (msg.IsAgreed) { T.LogDebug("AGREED"); } else if (msg.IsSafe) { T.LogDebug("SAFE"); } T.LogDebug(" message."); T.LogDebug("Sent by " + msg.Sender + "."); T.LogDebug("Type is " + msg.Type + "."); if (msg.EndianMismatch == true) { T.LogDebug("There is an endian mismatch."); } else { T.LogDebug("There is no endian mismatch."); } SpreadGroup[] groups = msg.Groups; T.LogDebug("To " + groups.Length + " groups."); byte[] data = msg.Data; T.LogDebug("The data is " + data.Length + " bytes."); T.LogDebug("The message is: " + System.Text.Encoding.ASCII.GetString(data)); } else if (msg.IsMembership) { MembershipInfo info = msg.MembershipInfo; if (info.IsRegularMembership) { SpreadGroup[] groups = msg.Groups; T.LogDebug("Received a REGULAR membership."); T.LogDebug("For group " + info.Group + "."); T.LogDebug("With " + groups.Length + " members."); T.LogDebug("I am member " + msg.Type + "."); for (int i = 0; i < groups.Length; i++) { T.LogDebug(" " + groups[i]); } T.LogDebug("Group ID is " + info.GroupID); T.LogDebug("Due to "); if (info.IsCausedByJoin) { T.LogDebug("the JOIN of " + info.Joined + "."); } else if (info.IsCausedByLeave) { T.LogDebug("the LEAVE of " + info.Left + "."); } else if (info.IsCausedByDisconnect) { T.LogDebug("the DISCONNECT of " + info.Disconnected + "."); } else if (info.IsCausedByNetwork) { SpreadGroup[] stayed = info.Stayed; T.LogDebug("NETWORK change."); T.LogDebug("VS set has " + stayed.Length + " members:"); for (int i = 0; i < stayed.Length; i++) { T.LogDebug(" " + stayed[i]); } } } else if (info.IsTransition) { T.LogDebug("Received a TRANSITIONAL membership for group " + info.Group); } else if (info.IsSelfLeave) { T.LogDebug("Received a SELF-LEAVE message for group " + info.Group); } } else if (msg.IsReject) { // Received a Reject message T.LogDebug("Received a "); if (msg.IsUnreliable) { T.LogDebug("UNRELIABLE"); } else if (msg.IsReliable) { T.LogDebug("RELIABLE"); } else if (msg.IsFifo) { T.LogDebug("FIFO"); } else if (msg.IsCausal) { T.LogDebug("CAUSAL"); } else if (msg.IsAgreed) { T.LogDebug("AGREED"); } else if (msg.IsSafe) { T.LogDebug("SAFE"); } T.LogDebug(" REJECTED message."); T.LogDebug("Sent by " + msg.Sender + "."); T.LogDebug("Type is " + msg.Type + "."); if (msg.EndianMismatch == true) { T.LogDebug("There is an endian mismatch."); } else { T.LogDebug("There is no endian mismatch."); } SpreadGroup[] groups = msg.Groups; T.LogDebug("To " + groups.Length + " groups."); byte[] data = msg.Data; T.LogDebug("The data is " + data.Length + " bytes."); T.LogDebug("The message is: " + System.Text.Encoding.ASCII.GetString(data)); } else { T.LogDebug("Message is of unknown type: " + msg.ServiceType); } } catch (Exception e) { T.LogDebug("Exception: " + e); Environment.Exit(1); } }