Exemple #1
0
int main(int argc, char *argv[])
{
    int r;

    MX *mx = mxClient("localhost", NULL, "Echo");

    if (mx == NULL) {
        fprintf(stderr, "mxClient failed.\n");
        return 1;
    }

    ping_msg = mxRegister(mx, "Ping");
    echo_msg = mxRegister(mx, "Echo");

    fprintf(stderr, "Echo: ping_msg = %d.\n", ping_msg);
    fprintf(stderr, "Echo: echo_msg = %d.\n", echo_msg);

    mxSubscribe(mx, ping_msg, on_ping, NULL);

    r = mxRun(mx);

    fprintf(stderr, "Echo: mxRun returned %d.\n", r);

    if (r != 0) {
        fputs(mxError(), stderr);
    }

    mxDestroy(mx);

    return r;
}
Exemple #2
0
void fxRunProgram(txMachine* the, txString path)
{
	txString dot = strrchr(path, '.');
	if (dot) {
		if (!strcmp(dot, ".jsb") || !strcmp(dot, ".xsb"))
			fxLoadBinaryProgram(the, path);
	#ifdef mxParse
		else if (!strcmp(dot, ".js"))
			fxLoadTextProgram(the, path);
	#endif
		else
			mxError(C_EINVAL);
	}
	else
		mxError(C_EINVAL);
}