Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ************************************************************************
  #
  #  DivConq
  #
  #  http://divconq.com/
  #
  #  Copyright:
  #    Copyright 2014 eTimeline, LLC. All rights reserved.
  #
 #  License:
 #    See the license.txt file in the project's top-level directory for details.
 #
 #  Authors:
 #    * Andy White
 #
 ************************************************************************ */
 package divconq.script.inst.ctp;
 
 
 public class CtpSend extends Instruction {
 	public void run(final StackEntry stack) {
         String name = stack.stringFromSource("Name");
         
         if (StringUtil.isEmpty(name))
         	name = "CtpSend_" + stack.getActivity().tempVarName();
         
         String vname = name;
         
         Struct ss = stack.refFromSource("Session");
         
         if ((ss == null) || !(ss instanceof ApiSession)) {
         	stack.log().errorTr(531);
         	stack.resume();
         	return;
         }
         
         @SuppressWarnings("resource")
 		ApiSession sess = (ApiSessionss;
         
         Message msg = null;
         
         Struct ms = stack.refFromSource("Message");
         
         if ((ms != null) && !(ms instanceof NullStruct)) {
         	if (ms instanceof Message) {
         		msg = (Messagems;
         	}
         	else if (ms instanceof RecordStruct) {
         		msg = MessageUtil.fromRecord((RecordStructms);
         	} 
         	else {
     			stack.setState(.);
             	stack.log().errorTr(532);
             	stack.resume();
             	return;
         	}
         }
         else {
             Struct bdy = stack.refFromSource("Data");
             String ser = stack.stringFromSource("Service");
             String feat = stack.stringFromSource("Feature");
             String op = stack.stringFromSource("Op");
         	
             msg = new Message(serfeatopbdy);
         }
         
         if ((msg == null)) {
         	stack.log().errorTr(533);
         	stack.resume();
         	return;        	
         }
         
         if (stack.getInstruction().getXml().getName().equals("CtpSendForget")) {
         	sess.sendForgetMessage(msg);
 			stack.resume();
         }
         else {
         	sess.sendMessage(msgnew ServiceResult() {				
 				public void callback() {
 					stack.log().copyMessages(this);
 					
 					Message resp = this.getResult();
					if ((resp != null) && resp.hasField("Body"))
						rdata = resp.getField("Body");
		    		
		            stack.addVariable(vnamerdata);
					stack.resume();
				}
			});
        }
	}
	public void cancel(StackEntry stack) {
		// do nothing, this isn't cancellable
	}
New to GrepCode? Check out our FAQ X