theLink 10.0
Loading...
Searching...
No Matches
MqContextC_Service_CS_API

MqContextC - create and manage a service … More...

+ Collaboration diagram for MqContextC_Service_CS_API:

Functions

void csmqmsgque.MqContextC.ServiceCreate (string token, MqServiceCCB callback)
  C#: ctx.ServiceCreate(string token, MqServiceICB|MqServiceCCB|MqServiceIF callback) C-API
create a link between a service-token and a service-callback
 
void csmqmsgque.MqContextC.ServiceCreate (string token, MqServiceICB callback)
  C#: ctx.ServiceCreate(string token, MqServiceICB|MqServiceCCB|MqServiceIF callback) C-API
create a link between a service-token and a service-callback
 
void csmqmsgque.MqContextC.ServiceCreate (string token, MqServiceIF callback)
  C#: ctx.ServiceCreate(string token, MqServiceICB|MqServiceCCB|MqServiceIF callback) C-API
create a link between a service-token and a service-callback
 
void csmqmsgque.MqContextC.ServiceDelete (string token)
  C#: ctx.ServiceDelete(string token) C-API
delete a service. …
 
bool csmqmsgque.MqContextC.ServiceIsTransaction ()
  C#: bool ctx.ServiceIsTransaction() C-API
check if the ongoing-service-call belongs to a transaction …
 
void csmqmsgque.MqContextC.ServiceProxy (string token, int id=(int) MqSlaveE.OTHER)
  C#: ctx.ServiceProxy(string token, int id = (int)MqSlaveE.OTHER) C-API
create a service to link a master-context with a slave-context. …
 
void csmqmsgque.MqContextC.ServiceProxyCtx (string token, MqContextC target)
  C#: ctx.ServiceProxyCtx(string token, MqContextC target) C-API
same as MqServiceProxy but use an MqContextC as input.
 
bool csmqmsgque.MqContextC.ServiceProxyCtxExists (string token, MqContextC target)
  C#: bool ctx.ServiceProxyCtxExists(string token, MqContextC target) C-API
check if service who belongs to token is a proxy-service
 
void csmqmsgque.MqContextC.ServiceProxyRoundRobin (string token, string ident)
  C#: ctx.ServiceProxyRoundRobin(string token, string ident) C-API
create a proxy-service using Round-Robin as load-balancer …
 
void csmqmsgque.MqContextC.ServiceStorage (string token)
  C#: ctx.ServiceStorage(string token) C-API
setup a service listen on a MqContextC_ServiceApi_Identifer and save all read-data-package into the STORAGE
 
bool csmqmsgque.MqContextC.ServiceTokenCheck (string token)
  C#: bool ctx.ServiceTokenCheck(string token) C-API
in an ongoing-service-call check if the current MqContextC_ServiceApi_Identifer is token
 
bool csmqmsgque.MqContextC.ServiceTokenExists (string token)
  C#: bool ctx.ServiceTokenExists(string token) C-API
check if the MqContextC_ServiceApi_Identifer token is defined as ctx service …
 
string csmqmsgque.MqContextC.ServiceTokenGet ()
  C#: string ctx.ServiceTokenGet() C-API
in an ongoing-service-call get the current MqContextC_ServiceApi_Identifer
 

Detailed Description

MqContextC - create and manage a service …

To provide a service is the main purpose of a server and the main-purpose of a client/server connection is to call a service and to process the result.
A service can be defined on the server or on the client. On the server a service can be initial setup with MqServerSetupIF method and finally cleanup with MqServerCleanupIF.

‍A service is created with the MqServiceCreate and deleted with the MqServiceDelete.

A service can be created and deleted during the entire life-cycle of the server or the client. If the server/client-context is deleted all services of the are deleted also.

‍A MqServiceDelete is not required.

Creating or deleting a service is like granting or revoking the right to access a single feature.

eventloop

To receive a data-package on a service the event-loop have to be active. The event-loop ia always active on an synchronous-service-call . On a server the event-loop is started with MqProcessEvent at startup.
synchronous-service-call
A synchronous-service-call always block and enter the event-loop to wait for an answer
asynchronous-service-call
A asynchronous-service-call always return immediately and the possible result is received on a callback

callback

A callback is the function called by a service and required to receive data from remote.
A callback is created with MqServiceCreate or is part of the service-call.
A callback can be a service-identifer or a service-callback.
service-call with callback
SendEND_AND_CALLBACK, SendEND_AND_SUB, SendEND_AND_TRANSACTION
service-call without callback
SendEND, SendEND_AND_WAIT

Example from MyServer.cs define the service HLWO on the server-link-setup

using System;
using csmqmsgque;

namespace example {

  // package-item
  sealed class MyServer : MqContextC, MqServerSetupIF {

    // factory constructor
    public MyServer(MqContextC tmpl=null) : base(tmpl) {
    }

    // service to serve all incoming requests for token "HLWO"
    public void MyFirstService () {
      SendSTART();
      SendSTR("Hello World");
      SendRETURN();
    }

    // define a service as link between the token "HLWO" and the callback "MyFirstService"
    void MqServerSetupIF.ServerSetup() {
      ServiceCreate("HLWO", MyFirstService);
    }

    // package-main
    static void Main(string[] argv) {
  
      // create the "MyServer" factory… and the object
      var srv = MqFactoryCT<MyServer>.Add().New();

      try {
	srv.LinkCreate(argv);
	srv.ProcessEvent(MqWaitOnEventE.FOREVER);
      } catch (Exception ex) {
        srv.ErrorCatch (ex);
      }
      srv.Exit();
    }
  }
}

Function Documentation

◆ ServiceCreate() [1/3]

void csmqmsgque.MqContextC.ServiceCreate ( string token,
MqServiceCCB callback )
inline

C#: ctx.ServiceCreate(string token, MqServiceICB|MqServiceCCB|MqServiceIF callback) C-API
create a link between a service-token and a service-callback

Definition at line 1601 of file MqContextC.cs.

1601 {
1602 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1603 IntPtr callback_ptr = callback == null ? IntPtr.Zero : (IntPtr)GCHandle.Alloc(new MqCall(mkrt,callback));
1604 MkErrorE errVal = Mq.MqServiceCreate(mkrt, hdl, token_cstr, ServiceCall, callback_ptr, ServiceFree, null);
1605 Marshal.FreeHGlobal(token_cstr);
1606 MkErrorC.Check(hdl, errVal);
1607 }
csmqmsgque.MqMsgque Mq
static void Check(IntPtr ctx, MkErrorE err)
MkErrorE

◆ ServiceCreate() [2/3]

void csmqmsgque.MqContextC.ServiceCreate ( string token,
MqServiceICB callback )
inline

C#: ctx.ServiceCreate(string token, MqServiceICB|MqServiceCCB|MqServiceIF callback) C-API
create a link between a service-token and a service-callback

Definition at line 1610 of file MqContextC.cs.

1610 {
1611 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1612 IntPtr callback_ptr = callback == null ? IntPtr.Zero : (IntPtr)GCHandle.Alloc(new MqCall(mkrt,callback));
1613 MkErrorE errVal = Mq.MqServiceCreate(mkrt, hdl, token_cstr, ServiceCall, callback_ptr, ServiceFree, null);
1614 Marshal.FreeHGlobal(token_cstr);
1615 MkErrorC.Check(hdl, errVal);
1616 }

◆ ServiceCreate() [3/3]

void csmqmsgque.MqContextC.ServiceCreate ( string token,
MqServiceIF callback )
inline

C#: ctx.ServiceCreate(string token, MqServiceICB|MqServiceCCB|MqServiceIF callback) C-API
create a link between a service-token and a service-callback

Definition at line 1619 of file MqContextC.cs.

1619 {
1620 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1621 IntPtr callback_ptr = callback == null ? IntPtr.Zero : (IntPtr)GCHandle.Alloc(new MqCall(mkrt,callback));
1622 MkErrorE errVal = Mq.MqServiceCreate(mkrt, hdl, token_cstr, ServiceCall, callback_ptr, ServiceFree, null);
1623 Marshal.FreeHGlobal(token_cstr);
1624 MkErrorC.Check(hdl, errVal);
1625 }

◆ ServiceDelete()

void csmqmsgque.MqContextC.ServiceDelete ( string token)
inline

C#: ctx.ServiceDelete(string token) C-API
delete a service. …

Definition at line 1628 of file MqContextC.cs.

1628 {
1629 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1630 MkErrorE errVal = Mq.MqServiceDelete(mkrt, hdl, token_cstr);
1631 Marshal.FreeHGlobal(token_cstr);
1632 MkErrorC.Check(hdl, errVal);
1633 }

◆ ServiceIsTransaction()

bool csmqmsgque.MqContextC.ServiceIsTransaction ( )
inline

C#: bool ctx.ServiceIsTransaction() C-API
check if the ongoing-service-call belongs to a transaction …

Definition at line 1636 of file MqContextC.cs.

1636 {
1637 bool __retVal__L = Mq.MqServiceIsTransaction(hdl);
1638 return __retVal__L;
1639 }

◆ ServiceProxy()

void csmqmsgque.MqContextC.ServiceProxy ( string token,
int id = (int)MqSlaveE::OTHER )
inline

C#: ctx.ServiceProxy(string token, int id = (int)MqSlaveE.OTHER) C-API
create a service to link a master-context with a slave-context. …

Definition at line 1642 of file MqContextC.cs.

1642 {
1643 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1644 MkErrorE errVal = Mq.MqServiceProxy(mkrt, hdl, token_cstr, id);
1645 Marshal.FreeHGlobal(token_cstr);
1646 MkErrorC.Check(hdl, errVal);
1647 }

◆ ServiceProxyCtx()

void csmqmsgque.MqContextC.ServiceProxyCtx ( string token,
MqContextC target )
inline

C#: ctx.ServiceProxyCtx(string token, MqContextC target) C-API
same as MqServiceProxy but use an MqContextC as input.

Definition at line 1650 of file MqContextC.cs.

1650 {
1651 IntPtr target_hdl = MqContextC.getOBJ("MqContextC",target);
1652 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1653 MkErrorE errVal = Mq.MqServiceProxyCtx(mkrt, hdl, token_cstr, target_hdl);
1654 Marshal.FreeHGlobal(token_cstr);
1655 MkErrorC.Check(hdl, errVal);
1656 }

◆ ServiceProxyCtxExists()

bool csmqmsgque.MqContextC.ServiceProxyCtxExists ( string token,
MqContextC target )
inline

C#: bool ctx.ServiceProxyCtxExists(string token, MqContextC target) C-API
check if service who belongs to token is a proxy-service

Definition at line 1659 of file MqContextC.cs.

1659 {
1660 IntPtr target_hdl = MqContextC.getOBJ("MqContextC",target);
1661 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1662 bool __retVal__L = Mq.MqServiceProxyCtxExists(hdl, token_cstr, target_hdl);
1663 Marshal.FreeHGlobal(token_cstr);
1664 return __retVal__L;
1665 }

◆ ServiceProxyRoundRobin()

void csmqmsgque.MqContextC.ServiceProxyRoundRobin ( string token,
string ident )
inline

C#: ctx.ServiceProxyRoundRobin(string token, string ident) C-API
create a proxy-service using Round-Robin as load-balancer …

Definition at line 1668 of file MqContextC.cs.

1668 {
1669 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1670 IntPtr ident_cstr = Marshal.StringToHGlobalAnsi(ident);
1671 MkErrorE errVal = Mq.MqServiceProxyRoundRobin(mkrt, hdl, token_cstr, ident_cstr);
1672 Marshal.FreeHGlobal(token_cstr);
1673 Marshal.FreeHGlobal(ident_cstr);
1674 MkErrorC.Check(hdl, errVal);
1675 }

◆ ServiceStorage()

void csmqmsgque.MqContextC.ServiceStorage ( string token)
inline

C#: ctx.ServiceStorage(string token) C-API
setup a service listen on a MqContextC_ServiceApi_Identifer and save all read-data-package into the STORAGE

Definition at line 1678 of file MqContextC.cs.

1678 {
1679 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1680 MkErrorE errVal = Mq.MqServiceStorage(mkrt, hdl, token_cstr);
1681 Marshal.FreeHGlobal(token_cstr);
1682 MkErrorC.Check(hdl, errVal);
1683 }

◆ ServiceTokenCheck()

bool csmqmsgque.MqContextC.ServiceTokenCheck ( string token)
inline

C#: bool ctx.ServiceTokenCheck(string token) C-API
in an ongoing-service-call check if the current MqContextC_ServiceApi_Identifer is token

Definition at line 1686 of file MqContextC.cs.

1686 {
1687 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1688 bool __retVal__L = Mq.MqServiceTokenCheck(hdl, token_cstr);
1689 Marshal.FreeHGlobal(token_cstr);
1690 return __retVal__L;
1691 }

◆ ServiceTokenExists()

bool csmqmsgque.MqContextC.ServiceTokenExists ( string token)
inline

C#: bool ctx.ServiceTokenExists(string token) C-API
check if the MqContextC_ServiceApi_Identifer token is defined as ctx service …

Definition at line 1694 of file MqContextC.cs.

1694 {
1695 IntPtr token_cstr = Marshal.StringToHGlobalAnsi(token);
1696 bool __retVal__L = Mq.MqServiceTokenExists(hdl, token_cstr);
1697 Marshal.FreeHGlobal(token_cstr);
1698 return __retVal__L;
1699 }

◆ ServiceTokenGet()

string csmqmsgque.MqContextC.ServiceTokenGet ( )
inline

C#: string ctx.ServiceTokenGet() C-API
in an ongoing-service-call get the current MqContextC_ServiceApi_Identifer

Definition at line 1702 of file MqContextC.cs.

1702 {
1703 IntPtr __retVal__L = Mq.MqServiceTokenGet(hdl);
1704 return Marshal.PtrToStringAnsi(__retVal__L);
1705 }