Is Room supposed to contain a socket when a connected is opened?

7 views
Skip to first unread message

Ben Kuhl

unread,
May 24, 2013, 12:23:53 PM5/24/13
to portal_...@googlegroups.com
I'm using both portal and portal-java.

In my code, I can inject it, but this.room does not contain any sockets.

    @Wire
    Room room;

    @On
    @Reply
    public Workstation getWorkstation(Socket socket, @Data WorkstationRequest request) {
        //let the workstation talk to the socket
        request.getWorkstation().setSocket(socket);
        return request.getWorkstation();
    }

This may or may not be an actual problem.  Based on the following example I expected the socket to already be within Room.  Is this the intended functionality?

Ben Kuhl

unread,
May 24, 2013, 1:49:44 PM5/24/13
to portal_...@googlegroups.com
Through further investigation, the above code doesn't solve the issue.  But I'm still wondering if there's an underlying problem somewhere else given Room doesn't contain any sockets, so my java can't send anything back to the browser.

Donghwan Kim

unread,
May 26, 2013, 10:55:56 AM5/26/13
to portal_...@googlegroups.com
Hi Ben,

Any room instance is injected automatically, but you have to add a socket explicitly like this:

@Wire
Room room;

@On
public void open(Socket socket) {
    room.add(socket);
}

There is a special room containing every socket that connected to the application. It is called 'hall' and provided by the framework per app. By declaring a room variable with the name, 'hall' like as ChatHandler.java(Room hall;) or setting @Wire's value annotation to 'hall' (@Wire("hall") Room hallRoom).
https://github.com/flowersinthesand/portal-java/tree/portal-parent-0.6/core#hall

However, there was a big issue with the hall. So if you want to use the hall, you must consider that: https://github.com/ralscha/portal-demos/pull/3, https://github.com/ralscha/portal-demos/pull/4

Thanks,

-- Donghwan


On Sat, May 25, 2013 at 2:49 AM, Ben Kuhl <ben...@gmail.com> wrote:
Through further investigation, the above code doesn't solve the issue.  But I'm still wondering if there's an underlying problem somewhere else given Room doesn't contain any sockets, so my java can't send anything back to the browser.

--
You received this message because you are subscribed to the Google Groups "Portal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to portal_projec...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben Kuhl

unread,
May 28, 2013, 8:17:37 AM5/28/13
to portal_...@googlegroups.com
Excellent, thanks!
Reply all
Reply to author
Forward
0 new messages