+ Reply to Thread
Results 1 to 5 of 5

Thread: Plugin to Plugin Communication

Hybrid View

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Plugin to Plugin Communication

    Hello,

    I have a plugin that is servicing some client request. In the course of processing, I would like to initiate an asynchronous evaluation so the initial request can be satisfied more quickly. The secondary evaluation may be time consuming, but it can send a message back to the client whenever it is done. I know that interop requests can be used across extensions, but the code I have right now is all in the same extension. Does the processing logic for the secondary evaluation need to be wrapped in a Plugin to achieve this goal? If so, are interop requests required to access functionality across plugins in the same extension.

    Thanks!

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,210
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    You don't need to use an interop if the two plugins are in the same extension, and you can't use interop if the secondary logic isn't in a plugin at all. You can however do something that is asynchronous, either in the same plugin or in another class that can then contact the single plugin.

    To make things clearer, here's a use case.

    1. Plugin creates an instance of a Helper class, and passes in (either in the constructor or using a setter) "this" so that Helper can invoke any of the public methods in the Plugin.

    2. When the request comes in, plugin uses scheduled callback with a duration of 1 ms to spawn a separate thread. The callback invokes the needed method in Helper, passing in whatever info Helper needs to do its job. edit: getApi().scheduleExecution is the ONLY way you should create a separate thread on the server. Don't do it any other way.

    3. Plugin processes the other parts of the request.

    4. Eventually Helper finishes processing its part of the request, and invokes a public method in Plugin to pass the result back including whatever other info is needed so that Plugin can identify which request this was.

    5. Plugin sends whatever plugin messages or other plugin only tasks there are to finish up.

    If you prefer to have both of these be plugins, let me know and I'll point you to an example that has one plugin communicating with another one.
    Last edited by tcarr; 04-17-2012 at 08:24 PM.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for providing information about these different options. Where can I find the Plugin to Plugin example that you mentioned?

  4. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,210
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    There are several of our code examples that have this. One is the RejoinGame code example that was released with 5.3.2. Look at the AvatarChatWithRejoin plugin, which is a room level plugin. The same extension has a server level plugin named RejoinGameServerLevel.

    I don't think that we have a case of the second plugin returning a value later to the first one, but it should be pretty simple to do if that is needed.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  5. The Following User Says Thank You to tcarr For This Useful Post:

    JDB (04-18-2012)

  6. #5
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That example gave me the last of what I needed to know for now.
    Thanks!

+ 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