Chanel ID

how do you get the channel ID when you create the chanel doing this
ST1.openChannel(“chat”);
or this
SelectableChannel SC2;
or
SocketChannel SC;
if your only suosed to use one which one do you use ??? ;D :stuck_out_tongue:

PS are
SimTask and NIOConnection ment to work together

  • how do you set the port to lisen at :-[ ???

PPS how do you register a user or get User ID

[quote]how do you get the channel ID when you create the chanel doing this
ST1.openChannel(“chat”);
or this
SelectableChannel SC2;
or
SocketChannel SC;
if your only suosed to use one which one do you use Huh Grin Tongue
[/quote]
On the server side, you receive a Channel ID as the return value from SimTask.openChannel(channelName). You can use this Channel ID to reference the channel in the future (but not across server reboots). On the client side, you simply reference channels by name – no IDs are known to the client.

You shouldn’t ever have to use the raw NIO classes such as SocketChannel. If you need to open an artibrary connection on a remote server, use the Raw Socket Manager via SimTask (i.e. SimTask.openSocket, sendRawSocketData, closeSocket, etc.)

[quote]PS are
SimTask and NIOConnection ment to work together
[/quote]
You shouldn’t have to worry about NIOConnection. SimTask is your server-side view of the world.

[quote]+ how do you set the port to lisen at
[/quote]
In your deployment descriptor (deploy.xml for most of the examples) one of the parameter names is “port”. Also, if you are using the canned FakeDiscovery.xml, specify the port here as well.

[quote]PPS how do you register a user or get User ID
[/quote]
There should be a server-side class signed up as the SimUserListener for the application. When a user connects, the UserID is passed to the SimUserListener.userJoined call back. In most of the examples there is a “Boot” class that handles user logins/logouts. The Chat Test is an excellent example of most of the common idioms for user connection.

Hope that helps.

On the server side, you receive a Channel ID as the return value from SimTask.openChannel(channelName). You can use this Channel ID to reference the channel in the future (but not across server reboots). On the client side, you simply reference channels by name – no IDs are known to the client.
[/quote]
Actually thats not quite correct. Omn he client, you recieve a ClientChannel object in your joinedChannel callback.
Until you recevieve this, the channel is not ready for your use.

More then that, you CANT use them ina GLO because they arent serializable. (There are other good logical reasons too but thats a key one.)

[quote]PS are
SimTask and NIOConnection ment to work together
[/quote]
NIOConnection is only useful as a base class fro stack extension.

It shouldnt even be IN the docs you have now. Is it?

NIOconection is in the server API docs!!! :o

[quote]PPS how do you register a user or get User ID
[/quote]
There should be a server-side class signed up as the SimUserListener for the application. When a user connects, the UserID is passed to the SimUserListener.userJoined call back. In most of the examples there is a “Boot” class that handles user logins/logouts. The Chat Test is an excellent example of most of the common idioms for user connection.

Hope that helps.
[/quote]
i cannot create a userLisener when i do i get this erro

C:\Program Files\HSim\Cat101\src\cat101\Main.java:39: addUserListener(com.sun.gi.logic.GLOReference<? extends com.sun.gi.logic.SimUserListener>) in com.sun.gi.logic.SimTask cannot be applied to (com.sun.gi.logic.SimUserListener)
ST1.addUserListener(UserListen);
1 error

and this is my code
SimTask ST1;
ST1.addUserListener(UserListen);
private final SimUserListener UserListen = new SimUserListener() {
public void userJoined(UserID uid, Subject subject) {

    }

    public void userLeft(UserID uid) {
    }

};

You are trying to pass a GLO directly to a SImTask method.

You need to pass a GLOReference to the Simtask.
in general all GLOs shoudl be referenced through GLOReferences.

Take a look at the SwordWorld code and tutorial. I discuss this explicitly.

thanks i had a look a the batelboard code and changes some things in my own code 1. i added a boot method and so on now it compiles well so far all it dose is figurout the user iD and open 3 chanels but it dose not run i thinks this is my fault by movig it the lib folder and edited password.txt and SGS_config files and so on here is my deploy.xml files is it corect?? ??? :stuck_out_tongue: :-<?xml version=“1.0” encoding=“UTF-8” ?>

  • <!--

    –>

What did you put in lib?

(1) You need to put an entry in SGS-apps/conf that points to the directory where you put that deployment XML
(2) You need to make sure the port you are telling ti to use in the deployment XMl is not in use by someone else.
(3) You need to put your jar in the same directory as the deployment XML.

1 check
2. how
3 check

How:
(1)try netstat and see what ports are listed as “listening” when not running the server.
(2) when you run the server watch for exceptions in the log when it starts up
(3) COmment out everything in SGS-app.conf except your app to make sure you arnt conflicting with another app in the same server

Btw
“does not run” is not a very useful erro report.

What is it explicitly doing that you dont expect or not doing that you do expect?

in cmd.exe

java -jar SunGameServer
Unable to access jarfile SunGameServer

the filename is SunGameServer.jar

There should be a shell script right there that runs it as well.

how you run shell script on winXP

and i still get the same message when i d0 that :’( :’( :’(

SHow me what you are typing and what the response is. Also what directory are you in when you do this?

The shell script would either have to be run under Cygwin or re-written as a bat file for it to work in windows

You should be typing java -jar SunGameServer.jar

If you type dir you should see:

bin
lib
release
examples
etc
doc
README
SunGameServer.jar
SGSClient.jar

how do you rewrite the shell file(dose not work wen i open it in notepad and save it as a.bat file)

that is what i am typing (i tried SunGameServer.jar instead of just SunGameServer as well) but i was told to run it from the release file


@echo off

REM Command-line options for SGS:
REM 
REM    -I <url>    Provide a URL to the Install-spec which lists
REM               the game apps to be hosted on this backend
REM 
REM   -V          Verbose startup
REM 
REM   -C          (deprecated) Clear the datastore on startup.
REM                It is safer to remove the persistant_store
REM                directory manually.
REM 

set JAVA=c:\windows\system32

echo on
%JAVA%\java -jar SunGameServer.jar -V -I file:SGS-apps.conf %1%

This is how I ended up translating the .sh into a .bat. Hope it helps.

Kev

thanks 8)

Actually, in closer inspection , we’re both wrong.

you want to be in release/server when you run it/

A dir shoudl look like this:

apps
lib
SunGameServer.jar
startSGS.sh
startDiscovery.sh
SGS-apps.conf
passwd.txt