Can sfs support alreaddy made game ?

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

shravan.yadav
Posts: 15
Joined: 18 Jun 2012, 07:56

Can sfs support alreaddy made game ?

Postby shravan.yadav » 18 Jun 2012, 13:08

Hi,

I woul like to know that can port any any game which are already developed in android or other plateform withsfs 2x ?
if yes then how can i do for the same. From where I can found the sfs 2x.jar for the use of sfs lib.Where I have to write the code for server side ? Please let me know how should i start ?I download the sfs 2x and install it. It is look like command promt .What is use of this ?


Thanks
Shravan
User avatar
Bax
Site Admin
Posts: 4482
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Can sfs support alreaddy made game ?

Postby Bax » 19 Jun 2012, 07:09

What do you mean with "port"? If you think you just have to connect your existing game to SmartFoxServer and it becomes a multiplayer game out-of-the-box, then you are wrong. Games must be designed to be multiplayer. Of course you can convert an existing game, but it is not a matter of a few lines of code.
We strongly recommend that you read the documentation and check the examples. This will answer to most of your questions.
Paolo Bax
The SmartFoxServer Team
shravan.yadav
Posts: 15
Joined: 18 Jun 2012, 07:56

Re: Can sfs support alreaddy made game ?

Postby shravan.yadav » 20 Jun 2012, 07:33

Thanks for reply.

I have some confusion ,suppose I make a hello world application in android, now i want this application treat as a multiplayer game .what steps should be take for this ?
I have install the sfs2x in my machine and start it and using android sdk i made the hello word aplication .Now using sfs2x libreary am trying to connect to sfs2x but it is not happening .I am using SmartFox class for the connection.I am taking 127.0.0.1 ip and port 9933 and also tried for localhost ip and 8080 port. Please help me . code:
package com.nextgen;

import com.smartfoxserver.v2.exceptions.SFSException;

import sfs2x.client.SmartFox;
import sfs2x.client.core.BaseEvent;
import sfs2x.client.core.IEventListener;
import sfs2x.client.core.SFSEvent;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class HelloAndroidActivity extends Activity implements IEventListener {
/** Called when the activity is first created. */

SmartFox sfsClient;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try{
sfsClient = new SmartFox(true);
initSmartFox();
//sfsClient.getRoomList();
sfsClient.connect("172.16.16.62",8080);// sfsClient.connect("127.0.0.1",9933);
boolean b;

b=sfsClient.isConnected();
Log.v("Is Connected ", " "+b);

// Log.v("Shravan Tag for ",sfsClient.getCurrentZone());
// Log.v("Shravan Tag for ",sfsClient.getSessionToken());
// Log.v("Shravan Tag for ",sfsClient.getVersion());
Log.v("shravan tag",""+sfsClient.isJoining());
}
catch(Exception e){

Log.v("Shravan Tag", e.toString());
Log.v("shravan Tag:getStackTrace()", ""+e.getStackTrace());
Log.v("shravan Tag:getCause()", e.getCause().toString());
Log.v("shravan tag:getLocalizedMessage()", e.getLocalizedMessage().toString());
Log.v("Shravan Tag:getMessage(", e.getMessage());
}
}

private void initSmartFox()
{
// Instantiate SmartFox client
Log.v("Shravan Tag2", "this is tag2");

Log.v("Shravan Tag3", "this is tag3");
// Add event listeners
sfsClient.addEventListener(SFSEvent.CONNECTION, this);
Log.v("Shravan Tag4", "this is tag4");
sfsClient.addEventListener(SFSEvent.CONNECTION_LOST, this);
Log.v("Shravan Tag5", "this is tag5");
sfsClient.addEventListener(SFSEvent.LOGIN, this);
Log.v("Shravan Tag6", "this is tag6");
sfsClient.addEventListener(SFSEvent.ROOM_JOIN, this);
Log.v("Shravan Tag7", "this is tag7");
sfsClient.addEventListener(SFSEvent.HANDSHAKE, this);
Log.v("Shravan Tag8", "this is tag8");


// Displays the connect dialog box so the user can enter the server IP and port.

}

public void dispatch(BaseEvent arg0) throws SFSException {

}
}
User avatar
Bax
Site Admin
Posts: 4482
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Can sfs support alreaddy made game ?

Postby Bax » 20 Jun 2012, 13:39

I'm sorry but we don't provide code reviews. Make sure you read the documentation and check the examples.
Paolo Bax
The SmartFoxServer Team
shravan.yadav
Posts: 15
Joined: 18 Jun 2012, 07:56

Re: Can sfs support alreaddy made game ?

Postby shravan.yadav » 21 Jun 2012, 05:01

Hi,
Sorry for disturb you .........
I am not saying to reveiew my code . I just want to know that what ip address and port shoud be there for the sfs2x conection ?I am geting socketLayer error ?How should i solve this problem . I am running the given example only which is in doc .

Thanks
User avatar
Bax
Site Admin
Posts: 4482
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Can sfs support alreaddy made game ?

Postby Bax » 21 Jun 2012, 09:07

If you run the example on the same machine on which SFS runs, and if you didn't change the default SFS configuration, then you should connect to 127.0.0.1, port 9933
Paolo Bax
The SmartFoxServer Team
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Can sfs support alreaddy made game ?

Postby ThomasLund » 03 Jul 2012, 10:01

And running on a phone, you cannot!!! connect to 127.0.0.1, as that is local only. Need to change that on server and client side if you run it on your phone

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 2 guests