[SOLVED] client.SendMessage() fails inside Orbiter

All Union Platform questions, comments, feature requests, and bug reports.

client.SendMessage() fails inside Orbiter  

Postby toby » Wed 08 Aug 2012 11:44

Test case:
Add this line
Code: Select all
orbiter.getClientManager().getClient(e.getClientID()).sendMessage("CHAT_MESSAGE", "Private hi to you!");

to the function addOccupantListener
in the Orbiter Chat Room example http://www.unionplatform.com/?page_id=3318

Result:
Code: Select all
Error: getClientID is not defined
Source File: http://cdn.unioncloud.io/Orbiter_latest.js
Line: 4573


Workaround:
Code: Select all
orbiter.getClientManager().sendMessage("CHAT_MESSAGE", [ e.getClientID() ], null, "Private hi to you!");
toby
 
Posts: 162
Joined: Sun 24 Jun 2012 14:18

Re: client.SendMessage() fails inside Orbiter

Postby colin » Fri 24 Jan 2014 21:09

an update on this topic:

in Orbiter 2.1.0, the "test case" you list in your example works correctly without causing an error. it's possible that at the time of your original post a bug existed that caused an error, but i haven't confirmed that theory with any archived releases of Orbiter.

in the current version of Orbiter, you should not need any workarounds to make the code in your example work. if you can reproduce the error in the current version or Orbiter, please post example code.

thanks for taking the time to report this issue,
colin
colin
 
Posts: 232
Joined: Mon 17 Oct 2011 18:47

Re: client.SendMessage() fails inside Orbiter

Postby toby » Sun 09 Feb 2014 20:35

Yes - this particular bug is fixed in the current version.

The Version with the bug is:
//=============================================================================
// Orbiter_2.0.0.783_Release
// http://www.unionplatform.com
// Release Date: 26-July-2012
// (c) Copyright USER1 Subsystems Corporation
//=============================================================================

and the relevant code, starting at line 4562 is
Code: Select all
// ============================================================================
// MESSAGING
// ============================================================================

net.user1.orbiter.Client.prototype.sendMessage = function (messageName) {
  if (this.clientManager == null) {
    return;
  }
  // Delegate to ClientManager
  var rest = Array.prototype.slice.call(arguments).slice(1);
  var args = [messageName,
              [getClientID()], // <<<<< THIS IS THE OFFENDING LINE
              null];
  this.clientManager.sendMessage.apply(this.clientManager, args.concat(rest));
}


In the current version:
//==============================================================================
// Orbiter_2.1.1.856_Release
// http://www.unionplatform.com
// Release Date: 28-January-2014
// (c) Copyright USER1 Subsystems Corporation
//==============================================================================

It does appear that the (obvious) fix has been applied

// =============================================================================
// MESSAGING
// =============================================================================

Code: Select all
net.user1.orbiter.Client.prototype.sendMessage = function (messageName) {
  if (this.clientManager == null) {
    return;
  }
  // Delegate to ClientManager
  var rest = Array.prototype.slice.call(arguments).slice(1);
  var args = [messageName,
              [this.getClientID()], // <<<<<<<< FIX APPLIED HERE
              null];
  this.clientManager.sendMessage.apply(this.clientManager, args.concat(rest));
};

The missing "this." has been added.

There were a couple of similar cases:

- RoomManager.stopWatchingForRooms ... fixed by initializing recursive = false

- clientManager.getClientByUserID is unchanged ... might still fail if non-existent id is requested
since variable "theClient" is not initialized and then possibly tested without ever having been set as
if (theClient === null)
at line 5358 of the current version.
toby
 
Posts: 162
Joined: Sun 24 Jun 2012 14:18


Return to Union Platform

Online

Users browsing this forum: No registered users and 8 guests