import java.util.*;

import org.omg.CORBA.*;

import chat.*;





public class ChatServer extends _ChatServerIImplBase {

    private Vector listeners;



    public ChatServer(String name) {

        super(name);

        listeners = new Vector();

    }



    public void addListener(ChatListenerI listener) {

        listeners.addElement(listener);

    }



    public void sendMessage(String message) {

        System.out.println("sending message: "+message);

        for(int i=0; i<listeners.size(); i++) {

            ((ChatListenerI)listeners.elementAt(i)).messageReceived(message);

        }

    }



    public static void main(String args[]) {

        ORB orb = ORB.init();

        BOA boa = orb.BOA_init();

        ChatServerI server = new ChatServer(args[0]);

        boa.obj_is_ready(server);

        System.out.println(server+" is ready");

        boa.impl_is_ready();

    }

}

Copyright © 2014 Franz Inc., All Rights Reserved | Privacy Statement
Delicious Google Buzz Twitter Google+