mn8 Language Reference | Index    

JabberClient

SUMMARY: ATTRIBUTES SUMMARY  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: ATTRIBUTE DETAILS  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

Concept allow to paging messages to sent via a jabber server.

            Format of HTML message is:<body>...</body>
            Example:<body>Hello it is a <b>test</b>.</body>

Usage

This example connect to jabber Server with specified 'userID' and 'passwd' and sent 'message' message to 'send_to_user', until waiting for response.

            define JabberTest [                                                                                                      
                static : main ( $arg typeof Series ) [                                                                               
                    $instance typeof JabberTest                                                                                      
                                                                                                                         
                    $jabber = JabberClient.create("server.intranet", 5222)                                                           
                    $jabber.login("mn8Bot", "botpassword")                                                                           
                    $jabber.send("crow@server.intranet", "Hello Csabi")                                                              
                                                                                                                         
                    print "Waiting for response ..."                                                                                 
                    $resp = 0                                                                                                        
                    while( $jabber/response@length < 100 ) do [                                                                      
                        if ( $resp != $jabber/response@length ) then [                                                               
                            $resp = $jabber/response@length                                                                          
                                                                                                                         
                            if ( $jabber/response/item.getConceptType == "Element" ) then [                                          
                                print $jabber/response/item.toXML                                                                    
                            ] else [                                                                                                 
                                print $jabber/response/item/$resp.toXML                                                              
                            ]                                                                                                        
                        ]                                                                                                            
                    ]                                                                                                                 
                ] 
            ]
        

Version: 0.1
Authors:Szabo Csaba ()
Location:
Inherits: Concept

Attribute List

 @response TYPEOF Series LABEL "response"
top

Constructor List

create (String $host, Integer $port)
top

Method List

login (String $user, String $pwd)
send (String $to, String $message, String $html)
send (String $to, String $message)
addHandler (Concept $concept, String $methodName)
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Attribute Info

@response

Label:response
Type:Series
Is Static:false
Is Hidden:false
Show Empty:true

Contains the series of the responses that you get from the server.

top

Detailed Constructor Info

create (String $host, Integer $port)
Parameters:
$host :

The name of the jabber server to connect to.

$port :

The port of the jabber server to connect to.

Method to set up the jabber server host and port.

top

Detailed Method Info

login (String $user, String $pwd)
Parameters:
$user :

The username to log into jabber server with.

$pwd :

The password to log into jabber server with.

Returns:
Exceptions:
connectionException :
(Error)
Connection refuzed by Jabber server.

Method to log into Jabber server. This method established connection to jabber server.

                $jabber = JabberClient.create("server.intranet", 5222)                                                           
                
                $jabber.login("mn8Bot", "botpassword")

                -- the result is --
                Estabilish connection with specified jabber server and logining in 
                with specified username and password.                                                     
            

top
send (String $to, String $message, String $html)
Parameters:
$to :

The user to send the message to.

$message :

The text message to send.

$html :

The html message to send.

Returns:
Exceptions:
recipientException :
(Warning)
No recipient has been specified.
messageException :
(Warning)
No message text has been specified.
connectionException :
(Error)
Connection refuzed by Jabber server.

Method to send to specified user the specified message.

                $jabber = JabberClient.create("server.intranet", 5222)                                                           
                $jabber.login("mn8Bot", "botpassword")

                $jabber.send("crow@server.intranet", "Hello Crow", "<body><b>Hello</b> Crow</body>") 
                
                -- the result is --
                Estabilish connection with specified jabber server and logining in 
                with specified username and password.
                Send HTML formated 'Hello Crow' massage to specified user.                                                     
            

top
send (String $to, String $message)
Parameters:
$to :

The user to send the message to.

$message :

The text message to send.

Returns:
Exceptions:
recipientException :
(Warning)
No recipient has been specified.
messageException :
(Warning)
No message text has been specified.
connectionException :
(Error)
Connection refuzed by Jabber server.

Method to send to specified user the specified message.

                $jabber = JabberClient.create("server.intranet", 5222)                                                           
                $jabber.login("mn8Bot", "botpassword")

                $jabber.send("crow@server.intranet", "Hello Crow") 
               
                -- the result is --
                Estabilish connection with specified jabber server and logining in 
                with specified username and password.
                Send simple 'Hello Crow' message to specified user.                                                     
            

top
addHandler (Concept $concept, String $methodName)
Parameters:
$concept :Instance of current concept.
$methodName :The handler method name that will be called when JabberClient receive a message.
Returns:

Adds a handler to this JabberClient. Singature of handler method is :
methodName( $inst typeof JabberClient, $e typeof Element ), where

                define JabberTest [                                                                                                                
                    static : main ( $arg typeof Series ) [                                                                                         
                        $instance typeof JabberTest                                                                                                
                        $jabber = JabberClient.create("server.intranet", 5222)                                                                     
                        
                        $jabber.addHandler( $instance, "inMess")                                                                                  
        
                        $jabber.login("mn8Bot", "botpassword")                                                                                     
                        $jabber.send("crow@server.intranet", "Hello Crow")                                                                        
                        while( $jabber/response@length < 100 ) do [                                                                                
                        ]                                                                                                                  
                    ]                                                                                                                      
                    : inMess($inst typeof JabberClient, $e typeof Element ) [                                                                     
                        print $e.toXML                                                                                                             
                        $inst.send($e@fromId, $e.getValue)                                                                                         
                    ]                                                                                                                             
                ]                                                                                                                          
                -- the result is --  
                Estabilish connection with specified jabber server and logining in 
                with specified username and password.
                Send simple messages to specified user, while not received 100 
                messages from sender.                                                      
            

top