Main Menu  

   

Login Form  

   

(007) Coding a Request Handler

Details
MainExtension.java
package myExt;
import com.smartfoxserver.v2.extensions.SFSExtension;

public class MainExtension extends SFSExtension{
	@Override
	public void init()
	{
		addRequestHandler("SumNumbers", SumNumbersHandler.class);
	}
}
SumNumbersHandler.java
package myExt;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;

public class SumNumbersHandler extends BaseClientRequestHandler{
	@Override
	public void handleClientRequest(User user, ISFSObject objIn)
	{
		int numA = objIn.getInt("NumA");
		int numB = objIn.getInt("NumB");

		ISFSObject objOut = new SFSObject();
		objOut.putInt("NumC", numA + numB);

		send("SumNumbers", objOut, user);
	}
}
 
   
© 2004-2015 Genesis Rage