+ Reply to Thread
Results 1 to 6 of 6

Thread: Record chatting as history

  1. #1
    Member
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Record chatting as history

    I'm trying to build a database that keep tracks of all the private messages that are sent from one user to another. I tried looking at the PluginPigLatin example, but it only deals with Public messages. And then I looked at the PluginPrivateMessage example, and it tells me to override the request(). How do I know when the client is sending a private message? The client could be sending a different type of request like maybe login request? Should I need to set up some protocol of my own so it can parse through the type of request the user is actually sending?

    So in the request(), i'll have several case statement and dispatch the particular task based on the request. Does this work? Or am I thinking it all wrong?

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts

    When you override the request() method in a plugin, that's the method that will be invoked if the client sends a plugin request to this particular plugin. As far as I know, there's no current event that you can listen for private messages sent from one user to another user.

    If you need to track all the private messages, you can have your clients send a plugin request when they want to send a private message, with a tag saying it's a private message. The plugin can then relay it to the recipient, as a plugin private message, with a tag saying who it was from. This will slow things down of course, but so will storing all this in a database.

    If you are not concerned about reading all the messages before they arrive at destination, you can have each client cache messages, and periodically send a set of them to a plugin for storage into the database. You might miss a few messages this way, if the user closes his SWF.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Member
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Interesting. Then I guess I need to construct my own protocol or tag to denote the private message. Because I assume anything that the client sends over to the server the request method will be the first method call.

    Because eventually I will also need to record scores after a game has ended. Due to our approach all game logic is done on the client side. So at the end of the game, the client will just send the resulting score and I need it to update the player's score profile. So,

    Code:
    public void request(String userName, EsObjectRO requestParameters) {
      //determine the tag
      String requesttype = requestParameters.getString("requestType");
      if ( requesttype == "UPDATEGAMESCORE" ) {
         //update score
      }
      else if ( requesttype == "sendprivatemsg" ) {
        //record msg
      }
      ...
    }

  4. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    Yes, this is the way request methods for game plugins usually end up. If there are just a few possible types of requests, I use if, else if, else if. If there are lots of them, I make an enumeration of them all (with a mapping of requestType to the enum variable) then use a switch. Normally I make lots of small private methods for updateScore(...), recordMsg(...), etc.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  5. #5
    Member
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm....this is weird. Then ideally we would only have one plugin to handle the request(). Because if we create several plugins then how does ES know which request() would it go to? I'm really confused.

  6. #6
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    Ah, in the client you specify which plugin(s) a room is using. I'm not sure what happens if more than one implements PluginRequest. When it comes to games, creating the game makes a room that uses that plugin, so the plugin requests go to the right game plugin instead of to some other plugin.

    Jobe has more experience with the client end. Perhaps he will have time to post in this thread.
    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