Discussion list for Unity developers.
unity-dev at moock.org
Tue Feb 13 13:26:38 CST 2007
hi rui,
I'm not sure if the problem you are describing is a total communication
failure or just failure to send a particular UPC.
if you're using the default settings, when you connect to the server you
should receive UPCs indicating your client's ID, IP, and connection
time. for example:
<UPC><METH>upcSetClientID</METH><ARGS><ARG>104068</ARG></ARGS></UPC>
<UPC><METH>upcOnClientAttributeUpdate</METH><ARGS><ARG>null</ARG><ARG>null</ARG><ARG>104068</ARG><ARG>_IP</ARG><ARG>127.0.0.1</ARG></ARGS></UPC><UPC><METH>upcOnClientAttributeUpdate</METH><ARGS><ARG>null</ARG><ARG>null</ARG><ARG>104068</ARG><ARG>_CONNECTTIME</ARG><ARG>1171417074811</ARG></ARGS></UPC>
you should start your exploration of creating a PHP client by attempting
to receive those messages.
once you can do that, then try sending your custom upc. note, however,
that the format you tried (below) is the future Unity 3 format, which is
not yet supported. when working with Unity 2, you need to use the older
format. you can find the message ids in the rightmost column of the
table here:
http://moock.org/unity/metro/docs/general/upc/upcmessageref.html
for example "u14" is "loginClient".
And here is the older, more verbose format for a UPC sent to the server:
<UPC>
<ROOMID>roomID</ROOMID>
<METH>messageName</METH>
<ARGS>
<ARG>value1</ARG>
<ARG>value2</ARG>
<ARG>...</ARG>
<ARG>valuen</ARG>
</ARGS>
</UPC>
Here is the older, more verbose format for a UPC sent to the client:
<UPC>
<METH>messageName</METH>
<ARGS>
<ARG>value1</ARG>
<ARG>value2</ARG>
<ARG>...</ARG>
<ARG>valuen</ARG>
</ARGS>
</UPC>
colin
Discussion list for Unity developers. wrote:
> Hello,
>
> I've tried to send UPC message with a PHP script using the documentation
>
>
> http://moock.org/unity/metro/docs/general/upc/upcmessageref.html
> http://moock.org/unity/metro/docs/general/upc/index.html
>
> I've open a socket connexion (9101) with the unity server using the PHP
> function
>
> $unity_ip="udp://XXX.XXX.XXX.XXX";
> $unity_port="9101";
> $fp = fsockopen ($unity_ip, $unity_port);
>
> No error sent back, the connexion seems to take place
>
> But when a try to read the socket my program read nothing
>
> using :
> $res .= fread($fp, 1024);
> OR
> $res .= fgets($fp, 1024);
>
> Even if I try to read the socket before or after sending a UPC message
>
> Upc message for loggin I send:
> <U>
> <R>unity</R>
> <M>u14</M>
> <L>
>
> <A>admin</A><A>XXXXXX</A>
> </L>
> </U>
>
> I've tried "tcp" but the programme wait a long time before releasing the
> connexion with no info on the socket
>
> Something obvious I'm missing (I post the phpscript and the result of
> execution)?
>
> Rui
>
> Here is our result of the php execution:
> ----------------------------------------
> Start TEST
> Connexion to [udp://XXX.XXX.XXX.179] On Port [9101]
> Read the socket
> Message to send
>
> <U>
> <R>unity</R>
> <M>u14</M>
> <L>
>
> <A>admin</A><A>XXXXXXX</A>
> </L>
> </U>
>
> End to send
> Sending Message
> Characters sent==>[88]<==
> Socket read 100 times
> Unity Response ==>
>
> End Unity Response
> --------------------------------------------
>
> The PHP Script :
>
> <?php
>
> $unity_port=9101;
> $unity_ip="udp://XXX.XXX.XXX.179";
>
> echo "Start TEST\r\n";
> echo "Connexion to [".$unity_ip."] On Port [".$unity_port."]\r\n";
>
> $fp = fsockopen ($unity_ip, $unity_port);
>
> if(!$fp) {
> echo "$errstr ($errno)<br>\n";
> }
> else
> {
>
> //stream_set_blocking ( $fp, TRUE);
> $id_room="unity";
> $id_message="u14";
>
>
> $params[0]="admin";
> $params[1]="XXXXXX";
>
> //echo "Read the socket\r\n";
> //$res .= fgets ($fp, 1024);
> //$res .= fread($fp, 1024);
>
> $the_message=unity_message($id_room,$id_message,$params);
> echo "Message to send\r\n".$the_message."\r\nEnd to send\r\n";
>
> echo "Sending Message\r\n";
> $int_return = fputs ($fp, $the_message);
> echo "Characters sent==>[".$int_return."]<==\r\n";
> if($int_return)
> {
> $cpt=0;
> sleep (5);
> while ($cpt < 100)
> {
>
> $res .= fgets ($fp, 1024);
> $cpt++;
> }
> echo "Socket read ".$cpt." times\r\n";
> }
>
>
> echo "Unity Response ==>\r\n".$res."\r\nEnd Unity Response\r\n";
>
> fclose($fp);
>
> }
>
>
> function unity_message($id_room,$id_message,$params=array())
> {
> $request_xml="
> <U>
> <R>".$id_room."</R>
> <M>".$id_message."</M>
> <L>
>
> ";
> while (list($header, $value) = each($params))
> {
> $request_xml.="<A>".$value."</A>";
> }
>
> $request_xml.="
> </L>
> </U>
> ";
> return $request_xml;
> }
> ?>
>
> -----Original Message-----
> From: unity-dev-bounces at moock.org [mailto:unity-dev-bounces at moock.org]On
> Behalf Of Discussion list for Unity developers.
> Sent: vendredi 2 février 2007 19:58
> To: unity-dev at moock.org
> Subject: Re: ||unity-dev|| testing our server potential AND using PHP
> script to make admin requests
>
>
> 1) it sounds like you are hitting a thread limit either on the test
> machine or the server machine. try increasing the available threads on
> both systems. i'm also checking with Derek to see if there's anything
> else that might be causing the 900-client cap.
>
> 2) when using unity with languages other than ActionScript, you simply
> connect to the server, then communicate using raw UPC messages. a list
> of messages and responses is available here:
>
> http://moock.org/unity/metro/docs/general/upc/
>
> colin
>
>
>
> --
> you're a unity-dev subscriber. to unsubscribe, visit www.moock.org/mailman/listinfo/unity-dev/
>
> superb hosting for this list and moock.org is generously provided by Rackspace. See: http://www.rackspace.com/?supbid=moock