示例#1
0
/*--
Cat pdnet;Protocols;XMPP/Jabber;JEP-0030
Form
	dyxNode *XMPP_JEP30_QueryItems(char *to, char *node);
Description
	Queries items from a given jid and node.
--*/
dyxNode *XMPP_JEP30_QueryItems(char *to, char *node)
{
	char buf[16];
	dyxNode *n;
	char *tag;

	n=dyxNew("query");
	dyxSet(n, "xmlns",
		"http://jabber.org/protocol/disco#items");
	if(node)dyxSet(n, "node", node);

	gcrsprints(buf, "jep30-%d", jep30_seq++);
	tag=buf;

	XMPP_SendIQ(to, "get", tag, n);

	while(1)
	{
		n=XMPP_CheckResults(tag);
		if(n)break;
		NET_Poll();
	}

	return(dyxChild(dyxChild(n)));
}
示例#2
0
文件: host.c 项目: odnarb/manquake
/*
==================
Host_Frame

Runs all active servers
==================
*/
void _Host_Frame (float time)
{
	if (setjmp (host_abortserver))
		return;			// something bad happened, or the server disconnected

// keep the random time dependent
	rand ();

// decide the simulation time
	if (!Host_FilterTime (time))
		return;			// don't run too fast, or packets will flood out

// get new key events
	Sys_SendKeyEvents ();

// process console commands
	Cbuf_Execute ();

	NET_Poll();

// check for commands typed to the host
	Host_GetConsoleCommands ();

	if (sv.active)
		Host_ServerFrame ();
}
示例#3
0
/*--
Cat pdnet;Protocols;XMPP/Jabber;JEP-0030
Form
	dyxNode *XMPP_JEP30_QueryItems(char *to, char *node);
Description
	Queries items from a given jid and node.
--*/
dyxNode *XMPP_JEP30_QueryItems(char *to, char *node)
{
	char buf[16];
	dyxNode *n;
	char *tag;

	n=dyxNewNode();
	n->key=kstrdup("query");
	dyxAddAttr(n, "xmlns",
		"http://jabber.org/protocol/disco#items");
	if(node)dyxAddAttr(n, "node", node);

	kprints(buf, "jep30-%d", jep30_seq++);
	tag=buf;

	XMPP_SendIQ(to, "get", tag, n);

	while(1)
	{
		n=XMPP_CheckResults(tag);
		if(n)break;
		NET_Poll();
	}

	return(n->first->first);
}
示例#4
0
void TTY_Shutdown(void)
{
	int		n;
	ComPort *p;

	for (n = 0; n < NUM_COM_PORTS; n++)
	{
		p = handleToPort[n];
		if (p->enabled)
		{
			while (p->modemConnected)
				NET_Poll();
			ComPort_Disable (p);
		}
	}
}
示例#5
0
文件: host.c 项目: libretro/tyrquake
/*
==================
Host_Frame

Runs all active servers
==================
*/
void
_Host_Frame(float time)
{
   /* something bad happened, or the server disconnected */
   if (setjmp(host_abort))
      return;

   /* keep the random time dependent */
   rand();

   /*
    * Decide the simulation time. Don't run too fast, or packets will flood
    * out.
    */
   if (!Host_FilterTime(time))
      return;

   /* get new key events */
   Sys_SendKeyEvents();

   /* allow mice or other external controllers to add commands */
   IN_Commands();

   /* process console commands */
   Cbuf_Execute();

   NET_Poll();

   /* if running the server locally, make intentions now */
   if (sv.active)
      CL_SendCmd();

   //-------------------
   //
   // server operations
   //
   //-------------------

   /* check for commands typed to the host */
   Host_GetConsoleCommands();

   if (sv.active)
      Host_ServerFrame();

   //-------------------
   //
   // client operations
   //
   //-------------------

   /*
    * if running the server remotely, send intentions now after the incoming
    * messages have been read
    */
   if (!sv.active)
      CL_SendCmd();

   host_time += host_frametime;

   /* fetch results from server */
   if (cls.state >= ca_connected)
      CL_ReadFromServer();

   SCR_UpdateScreen();
   CL_RunParticles();

   host_framecount++;
   fps_count++;
}
示例#6
0
qsocket_t *NET_Connect (char *host)
{
	qsocket_t		*ret;
	int				n;

	SetNetTime();

	if (host && *host == 0)
		host = NULL;

	if (host && hostCacheCount)
	{
		for (n = 0; n < hostCacheCount; n++)
			if (Q_strcasecmp (host, hostcache[n].name) == 0)
			{
				host = hostcache[n].cname;
				break;
			}
		if (n < hostCacheCount)
			goto JustDoIt;
	}

	slistSilent = host ? true : false;
	NET_Slist_f ();

	while(slistInProgress)
		NET_Poll();

	if (host == NULL)
	{
		if (hostCacheCount != 1)
			return NULL;
		host = hostcache[0].cname;
		Con_Printf("Connecting to...\n%s @ %s\n\n", hostcache[0].name, host);
	}

	if (hostCacheCount)
		for (n = 0; n < hostCacheCount; n++)
			if (Q_strcasecmp (host, hostcache[n].name) == 0)
			{
				host = hostcache[n].cname;
				break;
			}

JustDoIt:
	for (net_driverlevel=0 ; net_driverlevel<net_numdrivers; net_driverlevel++)
	{
		if (net_drivers[net_driverlevel].initialized == false)
			continue;
		ret = dfunc.Connect (host);
		if (ret)
			return ret;
	}

	if (host)
	{
		Con_Printf("\n");
		PrintSlistHeader();
		PrintSlist();
		PrintSlistTrailer();
	}
	
	return NULL;
}
示例#7
0
/*
==================
Host_Frame

Runs all active servers
==================
*/
void _Host_Frame (float time)
{
	static double		time1 = 0;
	static double		time2 = 0;
	static double		time3 = 0;
	int			pass1, pass2, pass3;

	if (setjmp (host_abortserver) )
		return;			// something bad happened, or the server disconnected

// keep the random time dependent
	rand ();
	
// decide the simulation time
	if (!Host_FilterTime (time))
		return;			// don't run too fast, or packets will flood out
		
// get new key events
	Sys_SendKeyEvents ();

// allow mice or other external controllers to add commands
	IN_Commands ();

// process console commands
	Cbuf_Execute ();

	NET_Poll();

// if running the server locally, make intentions now
	if (sv.active)
		CL_SendCmd ();
	
//-------------------
//
// server operations
//
//-------------------

// check for commands typed to the host
	Host_GetConsoleCommands ();
	
	if (sv.active)
		Host_ServerFrame ();

//-------------------
//
// client operations
//
//-------------------

// if running the server remotely, send intentions now after
// the incoming messages have been read
	if (!sv.active)
		CL_SendCmd ();

	host_time += host_frametime;

// fetch results from server
	if (cls.state == ca_connected)
	{
		CL_ReadFromServer ();
	}

// update video
	if (host_speeds.value)
		time1 = Sys_FloatTime ();
		
	SCR_UpdateScreen ();

	if (host_speeds.value)
		time2 = Sys_FloatTime ();
		
// update audio
	if (cls.signon == SIGNONS)
	{
		S_Update (r_origin, vpn, vright, vup);
		CL_DecayLights ();
	}
	else
		S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
	
	// jkrige - fmod sound system (music)
	//CDAudio_Update();
	FMOD_MusicUpdate();
	// jkrige - fmod sound system (music)

	if (host_speeds.value)
	{
		pass1 = (time1 - time3)*1000;
		time3 = Sys_FloatTime ();
		pass2 = (time2 - time1)*1000;
		pass3 = (time3 - time2)*1000;
		Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",	pass1+pass2+pass3, pass1, pass2, pass3);
	}
	
	host_framecount++;

	fps_count++; // jkrige - fps counter
}
示例#8
0
void *jabberrpc_rpc_call(NET_Reference *ref, void **args)
{
	XMPP_RefInfo *ri;
	NetParse_Node *exp, *cur, *n, *n2, *lst;
	char *s, *t;
	int i;
	void *p;
	int bgbrpc;

	char *tag;

	kprint("Jabber-RPC: call\n");

	bgbrpc=!strcmp(ref->iface->name, "bgbrpc-jid");

	ri=ref->refinfo;

	lst=NULL;
	for(i=0; args[i]; i++)
	{
		if(!bgbrpc)
			n=XmlRpc_EncodeValue(args[i]);
			else n=BGBRPC_EncodeValue(args[i]);

		n2=n;
		n=NetParse_NewNode();
		n->key=kstrdup("value");
		n->first=n2;

		n2=n;
		n=NetParse_NewNode();
		n->key=kstrdup("param");
		n->first=n2;

		lst=NetParse_AddNodeEnd(lst, n);
	}

	n2=n;
	n=NetParse_NewNode();
	n->key=kstrdup("params");
	n->first=lst;

	exp=n;

	n=NetParse_NewNode();
	n->text=kstrdup(ri->obj);

	n2=n;
	n=NetParse_NewNode();
	n->key=kstrdup("methodName");
	n->first=n2;
	n->next=exp;

	n2=n;
	n=NetParse_NewNode();
	n->key=kstrdup("methodCall");
	n->first=n2;


	n2=n;
	n=NetParse_NewNode();
	n->key=kstrdup("query");
	n->first=n2;

	if(!bgbrpc)
		NetParse_AddAttr(n, "xmlns", "jabber:iq:rpc");
		else NetParse_AddAttr(n, "xmlns",
			"http://bgb-sys.sourceforge.net/bgb-rpc");

	tag=kalloc(16);
	kprints(tag, "rpc%d", jabberrpc_seq++);
	s=jabberrpc_encode_jid(ri);

	XMPP_SendIQ(s, "set", tag, n);
	NetParse_FreeNode(n);

//	s=kalloc(16384);
//	t=s;
//	t=kprints(t, "<?xml version=\"1.0\"?>\n");
//	t=NetParse_XML_PrintExpr(t, n);
//	t=kprints(t, "\n");

//	t=HttpNode_Post(ref, "text/xml", s, strlen(s));
//	kfree(s);

//	kprint("XML-RPC: got %s\n", t);

//	s=t;
//	exp=NetParse_XML_ParseExpr(&t);

//	if(exp)if(exp->key)if(!strcmp(exp->key, "?xml"))
//		exp=NetParse_XML_ParseExpr(&t);

	exp=NULL;
	while(!exp)
	{
		exp=JabberRPC_CheckResults(tag);
		NET_Poll();
	}

	if(!exp)
	{
		kprint("PDLIB: XML-RPC: Parsed invalid response\n");
		return(NULL);
	}
	if(!exp->key)
	{
		kprint("PDLIB: XML-RPC: Parsed invalid response\n");
		return(NULL);
	}

	if(!strcmp(exp->key, "methodResponse"))
	{
		n=NetParse_FindKey(exp->first, "params");
		cur=n->first;
		p=XmlRpc_DecodeValue(cur->first);
//		NetParse_FreeNode(exp);
		return(p);
	}

	return(NULL);
}
示例#9
0
文件: net_main.c 项目: MP2E/tyrquake
qsocket_t *
NET_Connect(const char *host)
{
    qsocket_t *ret;
    int i, n;
    int numdrivers = net_numdrivers;

    SetNetTime();

    if (host && *host == 0)
	host = NULL;

    if (host) {
	if (strcasecmp(host, "local") == 0) {
	    numdrivers = 1;
	    goto JustDoIt;
	}

	if (hostCacheCount) {
	    for (n = 0; n < hostCacheCount; n++)
		if (strcasecmp(host, hostcache[n].name) == 0) {
		    host = hostcache[n].cname;
		    break;
		}
	    if (n < hostCacheCount)
		goto JustDoIt;
	}
    }

    slistSilent = host ? true : false;
    NET_Slist_f();

    while (slistInProgress)
	NET_Poll();

    if (host == NULL) {
	if (hostCacheCount != 1)
	    return NULL;
	host = hostcache[0].cname;
	Con_Printf("Connecting to...\n%s @ %s\n\n", hostcache[0].name, host);
    }

    if (hostCacheCount)
	for (n = 0; n < hostCacheCount; n++)
	    if (strcasecmp(host, hostcache[n].name) == 0) {
		host = hostcache[n].cname;
		break;
	    }

  JustDoIt:
    for (i = 0; i < numdrivers; i++) {
	net_driver = &net_drivers[i];
	if (net_driver->initialized == false)
	    continue;
	ret = net_driver->Connect(host);
	if (ret)
	    return ret;
    }

    if (host) {
	Con_Printf("\n");
	PrintSlistHeader();
	PrintSlist();
	PrintSlistTrailer();
    }

    return NULL;
}
示例#10
0
/*
==================
Host_Frame

Runs all active servers
==================
*/
void _Host_Frame (double time)
{
	static double		time1 = 0;
	static double		time2 = 0;
	static double		time3 = 0;
	int			pass1, pass2, pass3;

	if (setjmp (host_abortserver) )
		return;			// something bad happened, or the server disconnected

// keep the random time dependent
	rand ();

// decide the simulation time
	if (!Host_FilterTime (time))
	{
#ifdef PROQUAKE_EXTENSION
		// JPG - if we're not doing a frame, still check for lagged moves to send
		if (!sv.active && (cl.movemessages > 2))
			CL_SendLagMove();
#endif
		return;			// don't run too fast, or packets will flood out

	}

// get new key events
#if !defined(MACOSX)
	Sys_SendKeyEvents ();
#endif // This is done in Windows and Linux.  Confirmed from pq350src

// allow mice or other external controllers to add commands
	IN_Commands (); // Baker: This is ONLY joystick

// process console commands
	Cbuf_Execute ();

	NET_Poll();

// if running the server locally, make intentions now
	if (sv.active)
		CL_SendCmd ();  // This is where mouse input is read
#ifdef WINDOWS_SCROLLWHEEL_PEEK
	else if (con_forcedup && key_dest == key_game) // Allows console scrolling when con_forcedup
		IN_MouseWheel ();	// Grab mouse wheel input
#endif

//-------------------
//
// server operations
//
//-------------------

// check for commands typed to the host
	Host_GetConsoleCommands ();

	if (sv.active)
		Host_ServerFrame ();

//-------------------
//
// client operations
//
//-------------------

// if running the server remotely, send intentions now after
// the incoming messages have been read
	if (!sv.active)
		CL_SendCmd ();

	host_time += host_frametime;

// fetch results from server
	if (cls.state == ca_connected)
		CL_ReadFromServer ();

	if (host_speeds.value)
		time1 = Sys_DoubleTime ();

// update video
	SCR_UpdateScreen ();

	if (host_speeds.value)
		time2 = Sys_DoubleTime ();

	if (cls.signon == SIGNONS)
	{
		// update audio
		S_Update (r_origin, vpn, vright, vup);
		CL_DecayLights ();
	}
	else
	{
		S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
	}

#ifdef PSP_MP3_SUPPORT
	if (bmg_type_changed == true)
	{
#endif
		CDAudio_Update();
#ifdef PSP_MP3_SUPPORT
		bmg_type_changed = false;
	}
#endif

	if (host_speeds.value)
	{
		pass1 = (time1 - time3)*1000;
		time3 = Sys_DoubleTime ();
		pass2 = (time2 - time1)*1000;
		pass3 = (time3 - time2)*1000;
		Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n", pass1+pass2+pass3, pass1, pass2, pass3);
	}

#ifdef SUPPORTS_DEMO_CONTROLS
	if (!cls.demoplayback && cl_demorewind.value)
	{
		Cvar_SetValueByRef (&cl_demorewind, 0);
		Con_Printf ("Demorewind is only enabled during playback\n");
	}
#endif

	host_framecount++;
	//frame speed counter
	fps_count++;//muff
}