// The DOWNLOAD service routine public static void DOWNLOAD(TPSVCINFO rqst) { if ((rqst.flags & ATMI.TPSENDONLY) == 0) { TUX.userlog("ERROR: Client not in receive mode"); ATMI.tpreturn(ATMI.TPFAIL, 0, null, 0, 0); // Return null message as client is not in receive mode return; } string fileName = StringUtils.ReadStringBuffer(rqst.data, rqst.len); try { FileStream fs = File.OpenRead(fileName); try { Send(fs, rqst.cd); } finally { fs.Close(); } ATMI.tpreturn(ATMI.TPSUCCESS, 0, null, 0, 0); } catch (FileNotFoundException eFileNotFound) { ServerUtils.ReturnReply(ATMI.TPFAIL, 0, eFileNotFound.Message); } }
public static void TEST(TPSVCINFO svcInfo) { string message = "Installation OK"; byte[] bytes = Encoding.Default.GetBytes(message); ByteBuffer reply = ATMI.tpalloc("STRING", null, bytes.Length + 1); reply.PutBytes(bytes); reply.PutByte(bytes.Length, 0); ATMI.tpreturn(ATMI.TPSUCCESS, 0, reply, 0, 0); }
public static void BRDCST_TOUPPER(TPSVCINFO rqst) { ByteBuffer message = StringUtils.NewStringBuffer("Forwarding request to service TOUPPER"); try { ATMI.tpbroadcast(null, null, "sample", message, 0, 0); } finally { ATMI.tpfree(message); } ATMI.tpforward("TOUPPER", rqst.data, rqst.len, 0); }
public static void NOTIFY_TOUPPER(TPSVCINFO rqst) { ByteBuffer message = StringUtils.NewStringBuffer("Your request is forwarded to the TOUPPER service"); try { ATMI.tpnotify(rqst.cltid, message, 0, 0); } finally { ATMI.tpfree(message); } ATMI.tpforward("TOUPPER", rqst.data, rqst.len, 0); }
// The TOUPPER service routine public static void TOUPPER(TPSVCINFO rqst) { ByteBuffer data = rqst.data; byte[] bytes = new byte[rqst.len - 1]; data.GetBytes(bytes); string s = Encoding.Default.GetString(bytes); s = s.ToUpper(); bytes = Encoding.Default.GetBytes(s); data.PutBytes(bytes); data.PutByte(bytes.Length, 0); ATMI.tpreturn(ATMI.TPSUCCESS, 0, data, 0, 0); }
public static void PUBLISH_TIME(TPSVCINFO svcinfo) { ByteBuffer message = StringUtils.NewStringBuffer("It is now " + DateTime.Now); try { ATMI.tppost("TIME", message, 0, 0); } catch (TPENOENT) { // EventBroker not running yet (ignored) } finally { ATMI.tpfree(message); } Thread.Sleep(1000); ATMI.tpacall("PUBLISH_TIME", null, 0, ATMI.TPNOREPLY); ATMI.tpreturn(ATMI.TPSUCCESS, 0, null, 0, 0); }
public static void FML32_TOUPPER(TPSVCINFO rqst) { ByteBuffer fbfr = rqst.data; int fldid = FML32.FIRSTFLDID; int occ = 0; while (FML32.Fnext(fbfr, ref fldid, ref occ)) { int occur = FML32.Foccur(fbfr, fldid); if (FML32.Fldtype(fldid) == FML32.FLD_STRING) { for (int i = 0; i < occur; i++) { string s = FML32.FgetString(fbfr, fldid, i); s = s.ToUpper(); FML32.Fchg(fbfr, fldid, i, s); } } occ = occur; // Skip to next field id } ATMI.tpreturn(ATMI.TPSUCCESS, 0, fbfr, 0, 0); }