Forum .LRN Q&A: Re: Chat with usernames

Collapse
2: Re: Chat with usernames (response to 1)
Posted by Gustaf Neumann on
Yes, of course it is possible. But no, there is no parameter.

Edit chat/tcl/chat-ajax-procs.tcl and add there after the definition of the class Chat the following method:

  Chat instproc user_name { user_id } {
      acs_user::get -user_id $user_id -array user
      return $user(name)
  }
...or return some other formatting in this method...

Background: The Chat class in chat-ajax-procs is a subclass of ::xo::Chat defined in xotcl-core, where the default behavior is defined. The default behavior can be changed in the subclass by overwriting the method without affecting the behavior of other subclasses. The default behavior is defined in xotcl-core as:

  Chat instproc user_name { user_id } {
      acs_user::get -user_id $user_id -array user
      return [expr {$user(screen_name) ne "" ? $user(screen_name) : $user(name)}]
  }
by defining an object specific method, it would be possible without much work to provide a different behavior per chat instance - which is certainly not needed in your case.