+ Reply to Thread
Results 1 to 7 of 7

Thread: plugin message not sending?

  1. #1
    Senior Member
    Join Date
    Oct 2011
    Posts
    114
    Thanks
    11
    Thanked 0 Times in 0 Posts

    plugin message not sending?

    So, I have a server wide extension (not a room plugin/extension) so far, it does a few things, like tell me how many people are in a room, or what room a specific user is in. that all works fine and well.

    however, i added a new method to tell me what are the most populated rooms. The logic works well, but for some reason, the message does not get back to the client. I then had the moethd be called for a differnt action tag, and it works there!

    Code:
     public void request(String playerName, EsObjectRO requestParameters) 
    	{
            EsObject messageIn = new EsObject();
            messageIn.addAll(requestParameters);
    
            String action = messageIn.getString(PluginConstants.ACTION);
    		
    		if (action.equals(PluginConstants.METHOD_A))//this works for some reason
    			doMethodB(playerName,messageIn);
                   if (action.equals(PluginConstants.METHOD_B))//the logic works, but the message is never sent!
    			doMethodB(playerName,messageIn);
    //....snip....
    maybe im missing something obvious, but its got me stumped. I do know that im sending off 2 request to the server at once, but both seem to run...but only 1 is sent back (2 different methods).

    oh, this is for es5.2.3 (yes, i know i should upgrade, but its a slow process thats kinda out of my control)
    also, i tried to print out the error message of getApi().sendPluginMessageToUser(user, messageOut); but, i dont know what to import to make it happen. the import that is in the docs doesnt seem to help.

    thanks

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,213
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    I strongly suggest that you use { } around the body of your IF. Also, your messageIn will have action = METHOD_A or action = METHOD_B, but it can't have both.

    I suggest that you log messageIn.toString to see the exact message you are getting, and possibly also add a logging line inside the {} of the body of the IF, so you can tell which method is about to be called.

    From experience, you might want to double check that when the client sends action = METHOD_B that the string is exactly the same as the string that the plugin is looking for. It's very easy to make a typo, or get a blank at the end of the string or a simple case mismatch.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,213
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    Quote Originally Posted by kablammyman View Post
    also, i tried to print out the error message of getApi().sendPluginMessageToUser(user, messageOut); but, i dont know what to import to make it happen. the import that is in the docs doesnt seem to help.
    I don't understand this part. Can you please rephrase?
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  4. #4
    Senior Member
    Join Date
    Oct 2011
    Posts
    114
    Thanks
    11
    Thanked 0 Times in 0 Posts
    I was logging everything that the server was getting, the logic it performed, and logged up to where it would send off the esobject over the wire...but the client wasn't getting it. It all looked great in the logs. In both cases i tested in the above example, the method i wanted to run was running, and the output was what was expected, but again, the client wouldn't get it when the "action tag" was the proper tag, only when i made methodB run with PluginConstants.METHOD_A.

    Anyway, with more digging, i figured that if i changed the order that the client would send the "doMethodB" request, things would work right. So, instead of sending it after PluginConstants.METHOD_A, it send PluginConstants.METHOD_B first, and now everything works. I don't understand why, but whatever.

    Also, what i was talking about in regard to getApi().sendPluginMessageToUser(user, messageOut); was that the return type (PluginPublicMessageResponse) didn't seem to be in the import com.electrotank.electroserver5.extensions.api.Plug inApiResponse; class. Therefore, i couldn't log any errors that may have been happening with the sendPluginMessageToUser call. (the code wouldn't even compile)
    Last edited by kablammyman; 05-15-2012 at 09:44 PM.

  5. #5
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,213
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    If you are using getApi().sendPluginMessageToUser, then it returns a response of PluginPrivateMessageResponse. You should import com.electrotank.electroserver5.extensions.api.Plug inPrivateMessageResponse.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  6. #6
    Senior Member
    Join Date
    Oct 2011
    Posts
    114
    Thanks
    11
    Thanked 0 Times in 0 Posts
    nevermind, id10t error (client side)
    Last edited by kablammyman; 05-19-2012 at 12:27 AM.

  7. #7
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,213
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    Do you have any part of the plugin code marked synchronized, or with a Lock on it?

    Do you see any error messages in the server logs? If a plugin request results in an exception being thrown (and not caught), often the client is disconnected immediately.

    What version of ES5 are you running? If it is not 5.3.2, you should consider updating to that version, because there's a known bug with the earlier versions that would (very rarely) cause the server to ignore a particular client's connection.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts