Server does not raise pubMsg internal event

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Server does not raise pubMsg internal event

Post by cemuzunlar »

"handleInternalEvent" is not called by server when a client sends a public message.

* Server logs shows that it is taking the pubMsg request from the client.
* zone.setPrivMsgInternalEvent(true); is called in the extensions init function.
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Code: Select all

zone.setPrivMsgInternalEvent(true)
This enables events for private messages not public ones.
In order for public messages events to be fired you should call:

Code: Select all

zone.setPubMsgInternalEvent(true)
in your init()
Lapo
--
gotoAndPlay()
...addicted to flash games
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Post by cemuzunlar »

Oh sorry. We already specified both of them because we need to handle both pubMsg and privMsg. I copy pasted the wrong one here.

privMsg is working but putMsg is not.
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Which server version please?
What language is being used for the extension code?
Lapo
--
gotoAndPlay()
...addicted to flash games
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Post by cemuzunlar »

Server version: 1.6.6
Extension language code is written in Java.

Code: Select all

public void init() {
    helper = ExtensionHelper.instance();
    zone = helper.getZone(this.getOwnerZone());
		
    zone.setPubMsgInternalEvent(true);
    zone.setPrivMsgInternalEvent(true);
}

public void handleInternalEvent(InternalEventObject ieo) {
    trace("handleInternalEvent " + ieo.getEventName());
}
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Post by cemuzunlar »

Did you have a chance to investigate the issue?
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Yes, and it works as expected.
The problem is probably somewhere else. A couple of suggestions:

1. make sure the extension is really used by the Zone your application connects to (e.g. trace some text in the init and verify it's outputted correctly when the server starts)

2. make sure there's no zone name mismatch (i.e. the client is connecting to that Zone)
Lapo
--
gotoAndPlay()
...addicted to flash games
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Post by cemuzunlar »

1-2) This problem appears in a big project and everything else is working well.

The server got the message from the client
<msg t='sys'><body action='pubMsg' r='8'><txt><![CDATA[test]]></txt></body></msg>

but it doesn't raise the handleInternalEvent. I also tried setting the
zone.setPubMsgInternalEvent(false);

With this setting, server should be broadcasting the message to all users in the room including the sender but server didn't send out any messages when it got the message:
<msg t='sys'><body action='pubMsg' r='8'><txt><![CDATA[test]]></txt></body></msg>

it is acting like we disabled the sendPublicMessage with
<DisabledSysActions>
<action>sendPublicMessage</action>
</DisabledSysActions>

but we didn't.
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

With this setting, server should be broadcasting the message to all users in the room including the sender but server didn't send out any messages when it got the message:
<msg t='sys'><body action='pubMsg' r='8'><txt><![CDATA[test]]></txt></body></msg>
Sorry which setting?
A public message is always sent to all users in the room, including the sender, regardless of any settings.

The fact that a public message doesn't go through sounds really really strange to me. It's a very basic request and there's no know bug. I am inclined to think that there's some other problem going on which prevent the message to get to its destination.

1st of all I'd recommend to see if the server is spitting out any errors when the message is sent. Another thing to check is making sure that the Room is not of type "Limbo" which suppresses any broadcast-type message.
Lapo
--
gotoAndPlay()
...addicted to flash games
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Post by cemuzunlar »

Lapo wrote:Sorry which setting?
A public message is always sent to all users in the room, including the sender, regardless of any settings.
if we set the zone.setPubMsgInternalEvent(true) then, when a client uses sendPublicMessage, the server will raise the handleInternalEvent with the pubMsg command instead of immediately dispatching it to the users in the room.

We can then handle the command and if we want, we can use extensionHelper's dispatchPublicMessage method to dispatch the processed public message to the users in the room.
Lapo wrote:1st of all I'd recommend to see if the server is spitting out any errors when the message is sent. Another thing to check is making sure that the Room is not of type "Limbo" which suppresses any broadcast-type message.
Server just shows that it received the message. No exception occurs.

When we checked the room settings in the Admin panel, everything seems ok. isGame = true, isLimbo = false.

The room is created with the following code:

Code: Select all

HashMap<String, String> params = new HashMap<String, String>();
			
			params.put("name", jsRequestedRoom.getDbId());
			params.put("maxU", jsRequestedRoom.getMaxUsers());
			params.put("maxS", "0");
			params.put("isGame", "true");
			params.put("isLimbo", "false");
			params.put("uCount", "false");
			
			try {				
				sfsNewRoom = s.getHelper().createRoom(s.getZone(), params, jsRequesterUser.getSfsUser(), false, false);
			} catch (ExtensionHelperException e) {
				e.printStackTrace();
			}
Maybe it is a problem on our side but we couldn't find the source of the problem. We currently solved our problem using sendPrivateMessage in the client side with the receiver parameter set to the sender user's id. We catch the privMsg event in the server and if sender=receiver, we dispatch the public message ourselves.
Last edited by cemuzunlar on 15 Jun 2009, 15:56, edited 1 time in total.
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

if we set the zone.setPubMsgInternalEvent(false) then, when a client uses sendPublicMessage, the server will raise the handleInternalEvent with the pubMsg command instead of immediately dispatching it to the users in the room.
I am confused :)
zone.setPubMsgInternalEvent(false) turns OFF any server side events and messages are immediately broadcasted to all clients

zone.setPubMsgInternalEvent(true) turns ON the server side events and messages are not dispatched immediately. They are first sent to the Zone extension which in turn will need decide what to do.

From your report it seems the opposite, but there's no bug like this as far as I can see.

I have a very simple Java extension that I used for testing:

Code: Select all

package test;

import java.util.*;

import it.gotoandplay.smartfoxserver.data.Room;
import it.gotoandplay.smartfoxserver.data.User;
import it.gotoandplay.smartfoxserver.data.Zone;
import it.gotoandplay.smartfoxserver.events.InternalEventObject;
import it.gotoandplay.smartfoxserver.exceptions.ExtensionHelperException;
import it.gotoandplay.smartfoxserver.exceptions.LoginException;
import it.gotoandplay.smartfoxserver.extensions.*;
import it.gotoandplay.smartfoxserver.lib.ActionscriptObject;

public class PubMsgTest extends AbstractExtension
{
	
	private Zone zone;
	private ExtensionHelper helper;

	
	public void init() 
	{
	    helper = ExtensionHelper.instance();
	    zone = helper.getZone(this.getOwnerZone());

	    zone.setPubMsgInternalEvent(true);
	}
	
	public void destroy()
	{
		//
	}
	
	public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
	{
		//
	}
	
	public void handleRequest(String cmd, String params[], User u, int fromRoom)
	{
		//
	}
	
	
	public void handleInternalEvent(InternalEventObject ieo)
	{
		trace("handleInternalEvent " + ieo.getEventName());
	}	
}
Works as expected... I don't know what else it could be.
Try this simple extension in a separate Zone and see if it works for you ... if it doesn't I'll be surprised.
Lapo
--
gotoAndPlay()
...addicted to flash games
sumeetparmar
Posts: 5
Joined: 01 May 2009, 08:20

pubMsg not being received

Post by sumeetparmar »

This is not working for me as well. Steps:

1. init(), zone.setPubMsgInternalEvent(true);
2. handleInternalEvent(), trace(event.getEventName());

I should see the pubMsg event name in the wrapper log file but I don't and the public messages which were working before are not being transmitted i.e. the basic chat is not working -- very strange. Other events like userJoin etc are fine. The room is created ok and sendObject() works fine from AS3. Here's the code:

Code: Select all

    public void init() {        
        Zone zone = ExtensionHelper.instance().getZone(this.getOwnerZone());
        zone.setPubMsgInternalEvent(true);
     }

    public void handleInternalEvent(InternalEventObject event) {
        String eventName = event.getEventName();
        trace("eventName = " + eventName);
    }
Insights?
-Sumeet
[/code]
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Is the extension a Zone Level one?
What SFS version is it?
Any errors when the extension starts?
Any errors when the pubMsg event should be fired?
Have you tried the example I posted earlier? That one works perfectly.
Lapo
--
gotoAndPlay()
...addicted to flash games
sumeetparmar
Posts: 5
Joined: 01 May 2009, 08:20

Post by sumeetparmar »

Oh! This is not a zone level extension but rather room level extension. The room is created by the client and the extension is attached to it as part of room creation.

I will try with zone level extension. Thanks for the speedy response!

-Sumeet
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Yes, those events work globally at Zone level, not a Room level.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply