Skip to main content
Participating Frequently
May 11, 2006
Question

Is it Possible to run application as backend

  • May 11, 2006
  • 1 reply
  • 371 views
Hi,
I want to know , is it possible to run the application as backend, it should send a popup message when any user receives a message from another user. i.e it should work as instant messanger.

Please help me how to do this.

Thanks for your time and consideration

regards
avanthika

    This topic has been closed for replies.

    1 reply

    May 11, 2006
    avanthika,
    Using various examples from FMS sites, I have created a messaging function that can be used in any FMS application. Here is what is required:

    - FMS Wiki's UserManager
    - Some type of person list
    - Alert component (or some other message window that can recieve parameters)
    - Click handler for person list datagrid select method to assign UserID
    - Message input form that contains Title text box and Message text box

    Listed below is some code for the public message routine (everyone receives message)
    // Client Side
    private function submitButtonClicked(p_evtObj:Object):Void
    {
    doCheckMessage();

    if(m_messageOk)
    {
    doSendMessage();
    }
    }
    private function doCheckMessage():Boolean
    {
    var titleText = m_titleText.text;
    var messageText = m_messageText.text;

    if(titleText == "" || messageText == "")
    {
    Alert.show("Please ensure all fields are filled in","System Message")
    m_messageOk = false;
    return m_messageOk;
    }else{
    m_messageOk = true;
    return m_messageOk;
    }
    }
    private function doSendMessage():Void
    {
    var titleText:String = m_titleText.text;
    var messageText:String = m_messageText.text;

    if(!_global.online)
    {
    Alert.show("Please connect before sending the message","System Message")
    }else
    {
    //Connection class object method
    k_CONNECTION.sendPublicMessage(messageText, titleText);
    __DialogWindow.deletePopUp();
    }

    }
    //NetConnection method
    public function sendPublicMessage(p_msg:String, p_title:String):Void
    {
    m_nc.call("SendPublicMessage",null, p_msg, p_title);
    }
    m_nc.receiveMessage = function(p_msg:String, p_title:String):Void
    {
    m_instance.ncReceiveMessage(p_msg, p_title);
    }
    private function ncReceiveMessage(p_msg:String, p_title:String):Void
    {
    Alert.show(p_msg, p_title, Alert.OK);
    }

    //Server side
    Client.prototype.SendPublicMessage = function(p_msg, p_title)
    {
    for (i = 0; i < application.clients.length; i++){
    application.clients .call("receiveMessage",null,p_msg, p_title)
    }

    }
    //Private Message routine (requires UserManager and List of People

    //People List
    // Updated addItem to add userID for the List component data needed by UserManager.getClientAt
    m_list.addItem({label:((userID == myUserID) ? "***" : "" )+user.name, data:userID});

    //create listener object and assign change method for the List component change event


    __listener.change = function(evt_obj:Object):Void
    {
    _global.selectedUserID = evt_obj.target.selectedItem.data
    }

    //Private message methods
    private function submitButtonClicked(p_evtObj:Object):Void
    {
    doCheckMessage();

    if(m_messageOk)
    {
    doSendMessage();
    }
    }

    private function doCheckMessage():Boolean
    {
    var titleText = m_titleText.text;
    var messageText = m_messageText.text;

    if(titleText == "" || messageText == "")
    {
    Alert.show("Please ensure all fields are filled in","System Message")
    m_messageOk = false;
    return m_messageOk;
    }else{
    m_messageOk = true;
    return m_messageOk;
    }
    }

    private function doSendMessage():Void
    {
    //selectedUserID is set by the List component select handler
    var userID:Number = selectedUserID;
    var titleText:String = m_titleText.text;
    var messageText:String = m_messageText.text;

    if(!_global.online)
    {
    Alert.show("Please connect before sending the message","System Message")
    }else if(_global.selectedUserID == undefined)
    {
    Alert.show("Please select a user from the People List","System Message")
    } else
    {
    __DialogWindow.deletePopUp();
    k_CONNECTION.sendPrivateMessage(userID, messageText, titleText);
    }

    }

    //Netconnection class
    public function sendPrivateMessage(p_id:Number, p_msg:String, p_title:String):Void
    {
    m_nc.call("SendPrivateMessage", null, p_id, p_msg, p_title)
    }

    m_nc.receiveMessage = function(p_msg:String, p_title:String):Void
    {
    m_instance.ncReceiveMessage(p_msg, p_title);
    }

    private function ncReceiveMessage(p_msg:String, p_title:String):Void
    {
    Alert.show(p_msg, p_title, Alert.OK, null, null, "warningIcon");
    }

    //ServerSide

    Client.prototype.SendPrivateMessage = function (p_id, p_msg, p_title)
    {
    //userManager created from Application onconnect...follow FMS Wiki instructions
    var clientObj = userManager.getClientAt(p_id);
    clientObj.call("receiveMessage",null, p_msg, p_title)
    }

    Sorry a bit long and not well commented...but you should be able to piece together the functions...