about 'Chat'

asked 2015-01-14 23:30:14 -0700

anonymous user


updated 2015-01-20 11:47:41 -0700

Nikhil Dabhade gravatar image

I am a starter both English and Java

Can I control the number of persons per channel by coding?

[Update] Do you ever have a similar example ? I know that asking for too much but not enough time..

public boolean acceptSessionJoiner(short sessionPort, String joiner, SessionOpts sessionOpts) { Log.i(TAG, "SessionPortListener.acceptSessionJoiner(" + sessionPort + ", " + joiner + ", " + sessionOpts.toString() + ")");

         * Accept anyone who can get our contact port correct.
        if (sessionPort == CONTACT_PORT) {
            return true;
        return false;

Finally, that right to see this part?

edit retag flag offensive close merge delete


I moved your second question in the original post

Nikhil Dabhade ( 2015-01-20 11:48:00 -0700 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-15 10:10:05 -0700

Nikhil Dabhade gravatar image

updated 2015-01-20 11:59:12 -0700


Yes. The host of the session can control who can and cannot join a channel (in case of chat). More specifically, the callback

acceptSessionJoiner(short sessionPort, String joiner, SessionOpts opts)

which is a part of SessionPortListener will let you accept or reject a session joiner. By limiting the number of peers here you can control the number of people per channel through coding

[Update] Adding example based on second part of the original question. Snippet based on simple sample service for android If you need to keep a count on the number of members in a session then inside acceptSessionJoiner you could have a variable keep track of the number of joiners

public boolean acceptSessionJoiner(short sessionPort, String joiner, SessionOpts sessionOpts) {
    if ((sessionPort == CONTACT_PORT) && (++numberOfJoiners <= MAX_NUM_OF_JOINERS)) {
        return true;
    } else {
        return false;

Note this was just a quick example to show you how it could be done and could be tailored as per your needs.


edit flag offensive delete publish link more


I really appreciate your help

p890413 ( 2015-01-20 17:17:28 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-01-14 23:30:14 -0700

Seen: 66 times

Last updated: Jan 20 '15