getPipe

(since )



Get a pipe object.

Description


object getPipe ( string pubid )

This method allow you to get a pipe by his pubid. You can give the pubid of a channel or user.

When you give to getPipe the pubid of an user, it will create a pipe for this user (in APE JSF user are not pipe object for performance purpose). When the pipe is created the event pipeCreate will be fired.

For multi pipe : You can get the pubid of a pipe by catching the event "multiPipeCreate" or "uniPipeCreate" (event fired each time a new pipe is created)

For user : You can get the pubid of a user by catching the event "userJoin" (event fired each time a new user is added to a channel and also when you join a channel for all user) or with the function getUser (see pipe docs)

Parameters


pubid
Pubid of the pipe

Return values


A pipe object

Examples


//ape var is a reference to APE instance
 
//Get a pipe
var myPipe = ape.getPipe('a852c20b3e5c9889c16fe4ac88abe98f');
 
//Send a message on the pipe
myPipe.send('Hello world');

getPipe on Multi Pipe
//ape var is a reference to APE instance
 
ape.join('testChannel');
 
//This sample is just here to show you how to intercept pipe pubid in pipeCreate event
ape.addEvent('multiPipeCreate', function(type, pipe, options) {
    //Get the pipe object
    var myPubid = ape.getPipe(pipe.getPubid());
 
    //Send a message on the pipe
    myPipe.send('Hello world');
});

getPipe on User
//ape var is a reference to APE instance
ape.join('testChannel');
 
ape.addEvent('userJoin', function(user, pipe) {
    //For performance purpose, user are not pipe in APE JSF. If you want to have a pipe from an user, use getPipe.
    //Transform all user into a pipe object
    var pipe = ape.getPipe(user.pubid);
 
    //Send 'Hello world' to the user
    pipe.send('Hello world');
});
 
 

See also


  • Protocol_Basics » = Uni pipe and Multi pipe with APE JSF = Pipe is the communication system in APE. This tutorial s... (Wiki)
  • APE Protocol Basics » [[category:protocol]] == General working == * APE works on a "Subscriber/Publisher" pattern. The... (Wiki)

User notes


# No comment

Post a note


User notes may be edited or deleted, and usually a note is deleted because of the following reasons:
  • Bugs: Instead report a bug
  • Missing documentation: report that as a bug.
  • Support questions: See the community for available options.

In other words, do not ask questions within the user notes.

Note <b>,<u>,<i> HTML tags are allowed in the posts and the note formatting is preserved. URLs will be turned into clickable links, JavaScipt and C code blocks enclosed in the <source="javascript">JS Code</source> and <source="c">C Code</source> tags will be source highlighted automatically.