repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.setClassLoader | public void setClassLoader (ClassLoader loader)
{
_loader = loader;
PresentsConnection conn = getConnection();
if (conn != null) {
conn.setClassLoader(loader);
}
} | java | public void setClassLoader (ClassLoader loader)
{
_loader = loader;
PresentsConnection conn = getConnection();
if (conn != null) {
conn.setClassLoader(loader);
}
} | [
"public",
"void",
"setClassLoader",
"(",
"ClassLoader",
"loader",
")",
"{",
"_loader",
"=",
"loader",
";",
"PresentsConnection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"conn",
".",
"setClassLoader",
"(",
"lo... | Configures this session with a custom class loader that will be used when unserializing
classes from the network. | [
"Configures",
"this",
"session",
"with",
"a",
"custom",
"class",
"loader",
"that",
"will",
"be",
"used",
"when",
"unserializing",
"classes",
"from",
"the",
"network",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L196-L203 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.endSession | @EventThread
public void endSession ()
{
_clmgr.clientSessionWillEnd(this);
// queue up a request for our connection to be closed (if we have a connection, that is)
Connection conn = getConnection();
if (conn != null) {
// go ahead and clear out our connection now to prevent funniness
setConnection(null);
// have the connection manager close our connection when it is next convenient
_conmgr.closeConnection(conn);
}
// if we don't have a client object, we failed to resolve in the first place, in which case
// we have to cope as best we can
if (_clobj != null) {
// and clean up after ourselves
try {
sessionDidEnd();
} catch (Exception e) {
log.warning("Choked in sessionDidEnd " + this + ".", e);
}
// release (and destroy) our client object
_clmgr.releaseClientObject(_clobj.username);
// we only report that our session started if we managed to resolve our client object,
// so we only report that it ended in the same circumstance
_clmgr.clientSessionDidEnd(this);
}
// we always want to clear ourselves out of the client manager
_clmgr.clearSession(this);
// clear out the client object so that we know the session is over
_clobj = null;
} | java | @EventThread
public void endSession ()
{
_clmgr.clientSessionWillEnd(this);
// queue up a request for our connection to be closed (if we have a connection, that is)
Connection conn = getConnection();
if (conn != null) {
// go ahead and clear out our connection now to prevent funniness
setConnection(null);
// have the connection manager close our connection when it is next convenient
_conmgr.closeConnection(conn);
}
// if we don't have a client object, we failed to resolve in the first place, in which case
// we have to cope as best we can
if (_clobj != null) {
// and clean up after ourselves
try {
sessionDidEnd();
} catch (Exception e) {
log.warning("Choked in sessionDidEnd " + this + ".", e);
}
// release (and destroy) our client object
_clmgr.releaseClientObject(_clobj.username);
// we only report that our session started if we managed to resolve our client object,
// so we only report that it ended in the same circumstance
_clmgr.clientSessionDidEnd(this);
}
// we always want to clear ourselves out of the client manager
_clmgr.clearSession(this);
// clear out the client object so that we know the session is over
_clobj = null;
} | [
"@",
"EventThread",
"public",
"void",
"endSession",
"(",
")",
"{",
"_clmgr",
".",
"clientSessionWillEnd",
"(",
"this",
")",
";",
"// queue up a request for our connection to be closed (if we have a connection, that is)",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",... | Forcibly terminates a client's session. This must be called from the dobjmgr thread. | [
"Forcibly",
"terminates",
"a",
"client",
"s",
"session",
".",
"This",
"must",
"be",
"called",
"from",
"the",
"dobjmgr",
"thread",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L341-L378 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.handleMessage | public void handleMessage (Message message)
{
// if the client has been getting crazy with the cheeze whiz, stick a fork in them; the
// first time through we end our session, subsequently _throttle is null and we just drop
// any messages that come in until we've fully shutdown
if (_throttle == null) {
// log.info("Dropping message from force-quit client", "conn", getConnection(),
// "msg", message);
return;
} else if (_throttle.throttleOp(message.received)) {
handleThrottleExceeded();
}
dispatchMessage(message);
} | java | public void handleMessage (Message message)
{
// if the client has been getting crazy with the cheeze whiz, stick a fork in them; the
// first time through we end our session, subsequently _throttle is null and we just drop
// any messages that come in until we've fully shutdown
if (_throttle == null) {
// log.info("Dropping message from force-quit client", "conn", getConnection(),
// "msg", message);
return;
} else if (_throttle.throttleOp(message.received)) {
handleThrottleExceeded();
}
dispatchMessage(message);
} | [
"public",
"void",
"handleMessage",
"(",
"Message",
"message",
")",
"{",
"// if the client has been getting crazy with the cheeze whiz, stick a fork in them; the",
"// first time through we end our session, subsequently _throttle is null and we just drop",
"// any messages that come in until we'v... | from interface Connection.MessageHandler | [
"from",
"interface",
"Connection",
".",
"MessageHandler"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L437-L452 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.dispatchMessage | protected void dispatchMessage (Message message)
{
_messagesIn++; // count 'em up!
// we dispatch to a message dispatcher that is specialized for the particular class of
// message that we received
MessageDispatcher disp = _disps.get(message.getClass());
if (disp == null) {
log.warning("No dispatcher for message", "msg", message);
return;
}
// otherwise pass the message on to the dispatcher
disp.dispatch(this, message);
} | java | protected void dispatchMessage (Message message)
{
_messagesIn++; // count 'em up!
// we dispatch to a message dispatcher that is specialized for the particular class of
// message that we received
MessageDispatcher disp = _disps.get(message.getClass());
if (disp == null) {
log.warning("No dispatcher for message", "msg", message);
return;
}
// otherwise pass the message on to the dispatcher
disp.dispatch(this, message);
} | [
"protected",
"void",
"dispatchMessage",
"(",
"Message",
"message",
")",
"{",
"_messagesIn",
"++",
";",
"// count 'em up!",
"// we dispatch to a message dispatcher that is specialized for the particular class of",
"// message that we received",
"MessageDispatcher",
"disp",
"=",
"_di... | Processes a message without throttling. | [
"Processes",
"a",
"message",
"without",
"throttling",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L457-L471 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.startSession | protected void startSession (Name authname, AuthRequest req, PresentsConnection conn,
Object authdata)
{
_authname = authname;
_areq = req;
_authdata = authdata;
setConnection(conn);
// resolve our client object before we get fully underway
_clmgr.resolveClientObject(_authname, this);
// make a note of our session start time
_sessionStamp = System.currentTimeMillis();
} | java | protected void startSession (Name authname, AuthRequest req, PresentsConnection conn,
Object authdata)
{
_authname = authname;
_areq = req;
_authdata = authdata;
setConnection(conn);
// resolve our client object before we get fully underway
_clmgr.resolveClientObject(_authname, this);
// make a note of our session start time
_sessionStamp = System.currentTimeMillis();
} | [
"protected",
"void",
"startSession",
"(",
"Name",
"authname",
",",
"AuthRequest",
"req",
",",
"PresentsConnection",
"conn",
",",
"Object",
"authdata",
")",
"{",
"_authname",
"=",
"authname",
";",
"_areq",
"=",
"req",
";",
"_authdata",
"=",
"authdata",
";",
"... | Initializes this client instance with the specified username, connection instance and
client object and begins a client session. | [
"Initializes",
"this",
"client",
"instance",
"with",
"the",
"specified",
"username",
"connection",
"instance",
"and",
"client",
"object",
"and",
"begins",
"a",
"client",
"session",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L494-L507 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.resumeSession | protected void resumeSession (AuthRequest req, PresentsConnection conn)
{
// check to see if we've already got a connection object, in which case it's probably stale
Connection oldconn = getConnection();
if (oldconn != null && !oldconn.isClosed()) {
log.info("Closing stale connection", "old", oldconn, "new", conn);
// close the old connection (which results in everything being properly unregistered)
oldconn.close();
}
// note our new auth request (so that we can deliver the proper bootstrap services)
_areq = req;
// start using the new connection
setConnection(conn);
// if a client connects, drops the connection and reconnects within the span of a very
// short period of time, we'll find ourselves in resumeSession() before their client object
// was resolved from the initial connection; in such a case, we can simply bail out here
// and let the original session establishment code take care of initializing this resumed
// session
if (_clobj == null) {
log.info("Rapid-fire reconnect caused us to arrive in resumeSession() before the " +
"original session resolved its client object " + this + ".");
return;
}
// we need to get onto the dobj thread so that we can finalize resumption of the session
_omgr.postRunnable(new Runnable() {
public void run () {
// now that we're on the dobjmgr thread we can resume our session resumption
finishResumeSession();
}
});
} | java | protected void resumeSession (AuthRequest req, PresentsConnection conn)
{
// check to see if we've already got a connection object, in which case it's probably stale
Connection oldconn = getConnection();
if (oldconn != null && !oldconn.isClosed()) {
log.info("Closing stale connection", "old", oldconn, "new", conn);
// close the old connection (which results in everything being properly unregistered)
oldconn.close();
}
// note our new auth request (so that we can deliver the proper bootstrap services)
_areq = req;
// start using the new connection
setConnection(conn);
// if a client connects, drops the connection and reconnects within the span of a very
// short period of time, we'll find ourselves in resumeSession() before their client object
// was resolved from the initial connection; in such a case, we can simply bail out here
// and let the original session establishment code take care of initializing this resumed
// session
if (_clobj == null) {
log.info("Rapid-fire reconnect caused us to arrive in resumeSession() before the " +
"original session resolved its client object " + this + ".");
return;
}
// we need to get onto the dobj thread so that we can finalize resumption of the session
_omgr.postRunnable(new Runnable() {
public void run () {
// now that we're on the dobjmgr thread we can resume our session resumption
finishResumeSession();
}
});
} | [
"protected",
"void",
"resumeSession",
"(",
"AuthRequest",
"req",
",",
"PresentsConnection",
"conn",
")",
"{",
"// check to see if we've already got a connection object, in which case it's probably stale",
"Connection",
"oldconn",
"=",
"getConnection",
"(",
")",
";",
"if",
"("... | Called by the client manager when a new connection arrives that authenticates as this
already established client. This must only be called from the congmr thread. | [
"Called",
"by",
"the",
"client",
"manager",
"when",
"a",
"new",
"connection",
"arrives",
"that",
"authenticates",
"as",
"this",
"already",
"established",
"client",
".",
"This",
"must",
"only",
"be",
"called",
"from",
"the",
"congmr",
"thread",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L513-L547 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.finishResumeSession | @EventThread
protected void finishResumeSession ()
{
// if we have no client object for whatever reason; we're hosed, shut ourselves down
if (_clobj == null) {
log.info("Missing client object for resuming session " + this + ".");
endSession();
return;
}
// make extra sure we have no lingering subscriptions
clearSubscrips(false);
// Update our client secret with the new auth request
_clobj.getLocal(ClientLocal.class).secret = getSecret();
// let derived classes do any session resuming
sessionWillResume();
// send off a bootstrap notification immediately as we've already got our client object
sendBootstrap();
// resend the throttle update if non-default
if (_messagesPerSec != Client.DEFAULT_MSGS_PER_SECOND) {
sendThrottleUpdate();
}
log.info("Session resumed " + this + ".");
} | java | @EventThread
protected void finishResumeSession ()
{
// if we have no client object for whatever reason; we're hosed, shut ourselves down
if (_clobj == null) {
log.info("Missing client object for resuming session " + this + ".");
endSession();
return;
}
// make extra sure we have no lingering subscriptions
clearSubscrips(false);
// Update our client secret with the new auth request
_clobj.getLocal(ClientLocal.class).secret = getSecret();
// let derived classes do any session resuming
sessionWillResume();
// send off a bootstrap notification immediately as we've already got our client object
sendBootstrap();
// resend the throttle update if non-default
if (_messagesPerSec != Client.DEFAULT_MSGS_PER_SECOND) {
sendThrottleUpdate();
}
log.info("Session resumed " + this + ".");
} | [
"@",
"EventThread",
"protected",
"void",
"finishResumeSession",
"(",
")",
"{",
"// if we have no client object for whatever reason; we're hosed, shut ourselves down",
"if",
"(",
"_clobj",
"==",
"null",
")",
"{",
"log",
".",
"info",
"(",
"\"Missing client object for resuming s... | This is called from the dobjmgr thread to complete the session resumption. We call some call
backs and send the bootstrap info to the client. | [
"This",
"is",
"called",
"from",
"the",
"dobjmgr",
"thread",
"to",
"complete",
"the",
"session",
"resumption",
".",
"We",
"call",
"some",
"call",
"backs",
"and",
"send",
"the",
"bootstrap",
"info",
"to",
"the",
"client",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L553-L581 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.safeEndSession | @AnyThread
protected void safeEndSession ()
{
if (!_omgr.isRunning()) {
log.info("Dropping end session request as we're shutting down " + this + ".");
} else {
_omgr.postRunnable(new Runnable() {
public void run () {
endSession();
}
});
}
} | java | @AnyThread
protected void safeEndSession ()
{
if (!_omgr.isRunning()) {
log.info("Dropping end session request as we're shutting down " + this + ".");
} else {
_omgr.postRunnable(new Runnable() {
public void run () {
endSession();
}
});
}
} | [
"@",
"AnyThread",
"protected",
"void",
"safeEndSession",
"(",
")",
"{",
"if",
"(",
"!",
"_omgr",
".",
"isRunning",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Dropping end session request as we're shutting down \"",
"+",
"this",
"+",
"\".\"",
")",
";",
"... | Queues up a runnable on the object manager thread where we can safely end the session. | [
"Queues",
"up",
"a",
"runnable",
"on",
"the",
"object",
"manager",
"thread",
"where",
"we",
"can",
"safely",
"end",
"the",
"session",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L598-L610 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.unmapSubscrip | protected synchronized void unmapSubscrip (int oid)
{
ClientProxy rec;
synchronized (_subscrips) {
rec = _subscrips.remove(oid);
}
if (rec != null) {
rec.unsubscribe();
} else {
boolean alreadyDestroyed = _destroyedSubs.remove(oid);
if (!alreadyDestroyed) {
log.warning("Missing subscription in unmap", "client", this, "oid", oid);
}
}
} | java | protected synchronized void unmapSubscrip (int oid)
{
ClientProxy rec;
synchronized (_subscrips) {
rec = _subscrips.remove(oid);
}
if (rec != null) {
rec.unsubscribe();
} else {
boolean alreadyDestroyed = _destroyedSubs.remove(oid);
if (!alreadyDestroyed) {
log.warning("Missing subscription in unmap", "client", this, "oid", oid);
}
}
} | [
"protected",
"synchronized",
"void",
"unmapSubscrip",
"(",
"int",
"oid",
")",
"{",
"ClientProxy",
"rec",
";",
"synchronized",
"(",
"_subscrips",
")",
"{",
"rec",
"=",
"_subscrips",
".",
"remove",
"(",
"oid",
")",
";",
"}",
"if",
"(",
"rec",
"!=",
"null",... | Makes a note that this client is no longer subscribed to this object. The subscription map
is used to clean up after the client when it goes away. | [
"Makes",
"a",
"note",
"that",
"this",
"client",
"is",
"no",
"longer",
"subscribed",
"to",
"this",
"object",
".",
"The",
"subscription",
"map",
"is",
"used",
"to",
"clean",
"up",
"after",
"the",
"client",
"when",
"it",
"goes",
"away",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L637-L651 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.clearSubscrips | protected void clearSubscrips (boolean verbose)
{
for (ClientProxy rec : _subscrips.values()) {
if (verbose) {
log.info("Clearing subscription", "client", this, "obj", rec.object.getOid());
}
rec.unsubscribe();
}
_subscrips.clear();
} | java | protected void clearSubscrips (boolean verbose)
{
for (ClientProxy rec : _subscrips.values()) {
if (verbose) {
log.info("Clearing subscription", "client", this, "obj", rec.object.getOid());
}
rec.unsubscribe();
}
_subscrips.clear();
} | [
"protected",
"void",
"clearSubscrips",
"(",
"boolean",
"verbose",
")",
"{",
"for",
"(",
"ClientProxy",
"rec",
":",
"_subscrips",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"verbose",
")",
"{",
"log",
".",
"info",
"(",
"\"Clearing subscription\"",
",",
... | Clears out the tracked client subscriptions. Called when the client goes away and shouldn't
be called otherwise. | [
"Clears",
"out",
"the",
"tracked",
"client",
"subscriptions",
".",
"Called",
"when",
"the",
"client",
"goes",
"away",
"and",
"shouldn",
"t",
"be",
"called",
"otherwise",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L657-L666 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.sendBootstrap | protected void sendBootstrap ()
{
// log.info("Sending bootstrap " + this + ".");
// create and populate our bootstrap data
BootstrapData data = createBootstrapData();
populateBootstrapData(data);
// create a send bootstrap notification
postMessage(new BootstrapNotification(data), null);
} | java | protected void sendBootstrap ()
{
// log.info("Sending bootstrap " + this + ".");
// create and populate our bootstrap data
BootstrapData data = createBootstrapData();
populateBootstrapData(data);
// create a send bootstrap notification
postMessage(new BootstrapNotification(data), null);
} | [
"protected",
"void",
"sendBootstrap",
"(",
")",
"{",
"// log.info(\"Sending bootstrap \" + this + \".\");",
"// create and populate our bootstrap data",
"BootstrapData",
"data",
"=",
"createBootstrapData",
"(",
")",
";",
"populateBootstrapData",
"(",
"data",
")",
";",
... | This is called once we have a handle on the client distributed object. It sends a bootstrap
notification to the client with all the information it will need to interact with the
server. | [
"This",
"is",
"called",
"once",
"we",
"have",
"a",
"handle",
"on",
"the",
"client",
"distributed",
"object",
".",
"It",
"sends",
"a",
"bootstrap",
"notification",
"to",
"the",
"client",
"with",
"all",
"the",
"information",
"it",
"will",
"need",
"to",
"inte... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L735-L745 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.setConnection | protected synchronized void setConnection (PresentsConnection conn)
{
long now = System.currentTimeMillis();
if (_conn != null) {
// if our connection is being cleared out, record the amount of time we were connected
// to our total connected time
if (conn == null) {
_connectTime += ((now - _networkStamp) / 1000);
_messagesDropped = 0;
}
// make damn sure we don't get any more messages from the old connection
_conn.clearMessageHandler();
}
// keep a handle to the new connection
_conn = conn;
// if we're setting a connection rather than clearing one out...
if (_conn != null) {
// tell the connection to pass messages on to us
_conn.setMessageHandler(this);
// configure any active custom class loader
if (_loader != null) {
_conn.setClassLoader(_loader);
}
}
// make a note that our network status changed
_networkStamp = now;
} | java | protected synchronized void setConnection (PresentsConnection conn)
{
long now = System.currentTimeMillis();
if (_conn != null) {
// if our connection is being cleared out, record the amount of time we were connected
// to our total connected time
if (conn == null) {
_connectTime += ((now - _networkStamp) / 1000);
_messagesDropped = 0;
}
// make damn sure we don't get any more messages from the old connection
_conn.clearMessageHandler();
}
// keep a handle to the new connection
_conn = conn;
// if we're setting a connection rather than clearing one out...
if (_conn != null) {
// tell the connection to pass messages on to us
_conn.setMessageHandler(this);
// configure any active custom class loader
if (_loader != null) {
_conn.setClassLoader(_loader);
}
}
// make a note that our network status changed
_networkStamp = now;
} | [
"protected",
"synchronized",
"void",
"setConnection",
"(",
"PresentsConnection",
"conn",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"_conn",
"!=",
"null",
")",
"{",
"// if our connection is being cleared out, record t... | Sets our connection reference in a thread safe way. Also establishes the back reference to
us as the connection's message handler. | [
"Sets",
"our",
"connection",
"reference",
"in",
"a",
"thread",
"safe",
"way",
".",
"Also",
"establishes",
"the",
"back",
"reference",
"to",
"us",
"as",
"the",
"connection",
"s",
"message",
"handler",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L846-L877 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.finishCompoundMessage | protected void finishCompoundMessage ()
{
if (--_compoundDepth == 0) {
CompoundDownstreamMessage downstream = _compound;
_compound = null;
if (!downstream.msgs.isEmpty()) {
postMessage(downstream, null);
}
}
} | java | protected void finishCompoundMessage ()
{
if (--_compoundDepth == 0) {
CompoundDownstreamMessage downstream = _compound;
_compound = null;
if (!downstream.msgs.isEmpty()) {
postMessage(downstream, null);
}
}
} | [
"protected",
"void",
"finishCompoundMessage",
"(",
")",
"{",
"if",
"(",
"--",
"_compoundDepth",
"==",
"0",
")",
"{",
"CompoundDownstreamMessage",
"downstream",
"=",
"_compound",
";",
"_compound",
"=",
"null",
";",
"if",
"(",
"!",
"downstream",
".",
"msgs",
"... | Sends the compound message created in startCompoundMessage. | [
"Sends",
"the",
"compound",
"message",
"created",
"in",
"startCompoundMessage",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L928-L937 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.postMessage | protected boolean postMessage (DownstreamMessage msg, PresentsConnection expect)
{
PresentsConnection conn = getConnection();
// make sure that the connection they expect us to be using is the one we're using; there
// are circumstances were sufficient delay between request and response gives the client
// time to drop their original connection and establish a new one, opening the door to
// major confusion
if (expect != null && conn != expect) {
return false;
}
if (_compound != null) {
_compound.msgs.add(msg);
return true;
}
// make sure we have a connection at all
if (conn != null) {
conn.postMessage(msg);
_messagesOut++; // count 'em up!
return true;
}
// don't log dropped messages unless we're dropping a lot of them (meaning something is
// still queueing messages up for this dead client even though it shouldn't be)
if (++_messagesDropped % 50 == 0) {
log.warning("Dropping many messages?", "client", this,
"count", _messagesDropped, "msg", msg);
}
// make darned sure we don't have any remaining subscriptions
if (_subscrips.size() > 0) {
// log.warning("Clearing stale subscriptions", "client", this,
// "subscrips", _subscrips.size());
clearSubscrips(_messagesDropped > 10);
}
return false;
} | java | protected boolean postMessage (DownstreamMessage msg, PresentsConnection expect)
{
PresentsConnection conn = getConnection();
// make sure that the connection they expect us to be using is the one we're using; there
// are circumstances were sufficient delay between request and response gives the client
// time to drop their original connection and establish a new one, opening the door to
// major confusion
if (expect != null && conn != expect) {
return false;
}
if (_compound != null) {
_compound.msgs.add(msg);
return true;
}
// make sure we have a connection at all
if (conn != null) {
conn.postMessage(msg);
_messagesOut++; // count 'em up!
return true;
}
// don't log dropped messages unless we're dropping a lot of them (meaning something is
// still queueing messages up for this dead client even though it shouldn't be)
if (++_messagesDropped % 50 == 0) {
log.warning("Dropping many messages?", "client", this,
"count", _messagesDropped, "msg", msg);
}
// make darned sure we don't have any remaining subscriptions
if (_subscrips.size() > 0) {
// log.warning("Clearing stale subscriptions", "client", this,
// "subscrips", _subscrips.size());
clearSubscrips(_messagesDropped > 10);
}
return false;
} | [
"protected",
"boolean",
"postMessage",
"(",
"DownstreamMessage",
"msg",
",",
"PresentsConnection",
"expect",
")",
"{",
"PresentsConnection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"// make sure that the connection they expect us to be using is the one we're using; there",
... | Queues a message for delivery to the client. | [
"Queues",
"a",
"message",
"for",
"delivery",
"to",
"the",
"client",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L940-L978 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/PresentsSession.java | PresentsSession.throttleUpdated | protected void throttleUpdated ()
{
int messagesPerSec;
synchronized(_pendingThrottles) {
if (_pendingThrottles.size() == 0) {
log.warning("Received throttleUpdated but have no pending throttles",
"client", this);
return;
}
messagesPerSec = _pendingThrottles.remove(0);
}
// log.info("Applying updated throttle", "client", this, "msgsPerSec", messagesPerSec);
// We set our hard throttle over a 10 second period instead of a 1 second period to
// account for periods of network congestion that might cause otherwise properly
// throttled messages to bunch up while they're "on the wire"; we also add a one
// message buffer so that if the client is right up against the limit, we don't end
// up quibbling over a couple of milliseconds
_throttle.reinit(10*messagesPerSec+1, 10*1000L);
} | java | protected void throttleUpdated ()
{
int messagesPerSec;
synchronized(_pendingThrottles) {
if (_pendingThrottles.size() == 0) {
log.warning("Received throttleUpdated but have no pending throttles",
"client", this);
return;
}
messagesPerSec = _pendingThrottles.remove(0);
}
// log.info("Applying updated throttle", "client", this, "msgsPerSec", messagesPerSec);
// We set our hard throttle over a 10 second period instead of a 1 second period to
// account for periods of network congestion that might cause otherwise properly
// throttled messages to bunch up while they're "on the wire"; we also add a one
// message buffer so that if the client is right up against the limit, we don't end
// up quibbling over a couple of milliseconds
_throttle.reinit(10*messagesPerSec+1, 10*1000L);
} | [
"protected",
"void",
"throttleUpdated",
"(",
")",
"{",
"int",
"messagesPerSec",
";",
"synchronized",
"(",
"_pendingThrottles",
")",
"{",
"if",
"(",
"_pendingThrottles",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"log",
".",
"warning",
"(",
"\"Received throt... | Notifies this client that its throttle was updated. | [
"Notifies",
"this",
"client",
"that",
"its",
"throttle",
"was",
"updated",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsSession.java#L983-L1002 | train |
threerings/narya | core/src/main/java/com/threerings/presents/util/FutureResult.java | FutureResult.get | public V get (long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException
{
return _sync.innerGet(unit.toNanos(timeout));
} | java | public V get (long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException
{
return _sync.innerGet(unit.toNanos(timeout));
} | [
"public",
"V",
"get",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"ExecutionException",
",",
"TimeoutException",
"{",
"return",
"_sync",
".",
"innerGet",
"(",
"unit",
".",
"toNanos",
"(",
"timeout",
")",
")",
... | from interface Future | [
"from",
"interface",
"Future"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/FutureResult.java#L67-L71 | train |
threerings/narya | core/src/main/java/com/threerings/presents/util/FutureResult.java | FutureResult.requestProcessed | public void requestProcessed (Object result)
{
@SuppressWarnings("unchecked") V value = (V)result;
_sync.innerSet(value);
} | java | public void requestProcessed (Object result)
{
@SuppressWarnings("unchecked") V value = (V)result;
_sync.innerSet(value);
} | [
"public",
"void",
"requestProcessed",
"(",
"Object",
"result",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"V",
"value",
"=",
"(",
"V",
")",
"result",
";",
"_sync",
".",
"innerSet",
"(",
"value",
")",
";",
"}"
] | from interface InvocationService.ResultListener | [
"from",
"interface",
"InvocationService",
".",
"ResultListener"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/FutureResult.java#L74-L78 | train |
threerings/narya | core/src/main/java/com/threerings/admin/client/TabbedDSetEditor.java | TabbedDSetEditor.createEditor | protected DSetEditor<E> createEditor (
DObject setter, String setName, Class<?> entryClass, String[] editableFields,
ObjectEditorTable.FieldInterpreter interp, EntryGrouper<E> grouper, String group)
{
return new DSetEditor<E>(setter, setName, entryClass, editableFields,
interp, getDisplayFields(group), grouper.getPredicate(group));
} | java | protected DSetEditor<E> createEditor (
DObject setter, String setName, Class<?> entryClass, String[] editableFields,
ObjectEditorTable.FieldInterpreter interp, EntryGrouper<E> grouper, String group)
{
return new DSetEditor<E>(setter, setName, entryClass, editableFields,
interp, getDisplayFields(group), grouper.getPredicate(group));
} | [
"protected",
"DSetEditor",
"<",
"E",
">",
"createEditor",
"(",
"DObject",
"setter",
",",
"String",
"setName",
",",
"Class",
"<",
"?",
">",
"entryClass",
",",
"String",
"[",
"]",
"editableFields",
",",
"ObjectEditorTable",
".",
"FieldInterpreter",
"interp",
","... | Creates a DSetEditor for displaying the given group. | [
"Creates",
"a",
"DSetEditor",
"for",
"displaying",
"the",
"given",
"group",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/client/TabbedDSetEditor.java#L213-L219 | train |
threerings/narya | core/src/main/java/com/threerings/presents/peer/server/persist/NodeRecord.java | NodeRecord.getPeerHostName | public String getPeerHostName (String region)
{
return (ALWAYS_CONNECT_INTERNAL || Objects.equal(this.region, region))
? hostName
: publicHostName;
} | java | public String getPeerHostName (String region)
{
return (ALWAYS_CONNECT_INTERNAL || Objects.equal(this.region, region))
? hostName
: publicHostName;
} | [
"public",
"String",
"getPeerHostName",
"(",
"String",
"region",
")",
"{",
"return",
"(",
"ALWAYS_CONNECT_INTERNAL",
"||",
"Objects",
".",
"equal",
"(",
"this",
".",
"region",
",",
"region",
")",
")",
"?",
"hostName",
":",
"publicHostName",
";",
"}"
] | Returns the host name to which peers in the specified region should connect. | [
"Returns",
"the",
"host",
"name",
"to",
"which",
"peers",
"in",
"the",
"specified",
"region",
"should",
"connect",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/persist/NodeRecord.java#L117-L122 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.setClassLoader | public void setClassLoader (ClassLoader loader)
{
_loader = loader;
if (_comm != null) {
_comm.setClassLoader(loader);
}
} | java | public void setClassLoader (ClassLoader loader)
{
_loader = loader;
if (_comm != null) {
_comm.setClassLoader(loader);
}
} | [
"public",
"void",
"setClassLoader",
"(",
"ClassLoader",
"loader",
")",
"{",
"_loader",
"=",
"loader",
";",
"if",
"(",
"_comm",
"!=",
"null",
")",
"{",
"_comm",
".",
"setClassLoader",
"(",
"loader",
")",
";",
"}",
"}"
] | Configures the client with a custom class loader which will be used when reading objects off
of the network. | [
"Configures",
"the",
"client",
"with",
"a",
"custom",
"class",
"loader",
"which",
"will",
"be",
"used",
"when",
"reading",
"objects",
"off",
"of",
"the",
"network",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L292-L298 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.registerFlushDelay | public void registerFlushDelay (Class<?> objclass, long delay)
{
ClientDObjectMgr omgr = (ClientDObjectMgr)getDObjectManager();
omgr.registerFlushDelay(objclass, delay);
} | java | public void registerFlushDelay (Class<?> objclass, long delay)
{
ClientDObjectMgr omgr = (ClientDObjectMgr)getDObjectManager();
omgr.registerFlushDelay(objclass, delay);
} | [
"public",
"void",
"registerFlushDelay",
"(",
"Class",
"<",
"?",
">",
"objclass",
",",
"long",
"delay",
")",
"{",
"ClientDObjectMgr",
"omgr",
"=",
"(",
"ClientDObjectMgr",
")",
"getDObjectManager",
"(",
")",
";",
"omgr",
".",
"registerFlushDelay",
"(",
"objclas... | Instructs the distributed object manager associated with this client to allow objects of the
specified class to linger around the specified number of milliseconds after their last
subscriber has been removed before the client finally removes its object proxy and flushes
the object. Normally, objects are flushed immediately following the removal of their last
subscriber.
<p><em>Note:</em> the delay will be applied to derived classes as well as exact
matches. <em>Note also:</em> this method cannot be called until after the client has
established a connection with the server and the distributed object manager is available. | [
"Instructs",
"the",
"distributed",
"object",
"manager",
"associated",
"with",
"this",
"client",
"to",
"allow",
"objects",
"of",
"the",
"specified",
"class",
"to",
"linger",
"around",
"the",
"specified",
"number",
"of",
"milliseconds",
"after",
"their",
"last",
"... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L344-L348 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.logon | public synchronized boolean logon ()
{
// if we have a communicator reference, we're already logged on
if (_comm != null) {
return false;
}
// notify our observers immediately
_observers.apply(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientWillLogon(_client);
}
});
// create a new communicator and start it up; this will initiate the logon process
_comm = createCommunicator();
_comm.setClassLoader(_loader);
_comm.logon();
// register an interval to keep the clock synced and to send pings when appropriate
if (_tickInterval == null) {
_tickInterval = new Interval(_runQueue) {
@Override public void expired () {
tick();
}
@Override public String toString () {
return "Client.tickInterval";
}
};
_tickInterval.schedule(5000L, true);
}
return true;
} | java | public synchronized boolean logon ()
{
// if we have a communicator reference, we're already logged on
if (_comm != null) {
return false;
}
// notify our observers immediately
_observers.apply(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientWillLogon(_client);
}
});
// create a new communicator and start it up; this will initiate the logon process
_comm = createCommunicator();
_comm.setClassLoader(_loader);
_comm.logon();
// register an interval to keep the clock synced and to send pings when appropriate
if (_tickInterval == null) {
_tickInterval = new Interval(_runQueue) {
@Override public void expired () {
tick();
}
@Override public String toString () {
return "Client.tickInterval";
}
};
_tickInterval.schedule(5000L, true);
}
return true;
} | [
"public",
"synchronized",
"boolean",
"logon",
"(",
")",
"{",
"// if we have a communicator reference, we're already logged on",
"if",
"(",
"_comm",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// notify our observers immediately",
"_observers",
".",
"apply",
"(... | Requests that this client connect and logon to the server with which it was previously
configured.
@return false if we're already logged on, true if a logon attempt was initiated. | [
"Requests",
"that",
"this",
"client",
"connect",
"and",
"logon",
"to",
"the",
"server",
"with",
"which",
"it",
"was",
"previously",
"configured",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L504-L537 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.logoff | public boolean logoff (boolean abortable)
{
// if we have no communicator, we're not logged on anyway
if (_comm == null) {
log.warning("Ignoring request to logoff because we're not logged on.");
return true;
}
// if the request is abortable, let's run it past the observers before we act upon it
final boolean[] rejected = new boolean[] { false };
_observers.apply(new ObserverOps.Client(this) {
@Override protected void notify (ClientObserver obs) {
if (!obs.clientWillLogoff(_client)) {
rejected[0] = true;
}
}
});
if (abortable && rejected[0]) {
return false;
}
// ask the communicator to send a logoff message and disconnect from the server
_comm.logoff();
return true;
} | java | public boolean logoff (boolean abortable)
{
// if we have no communicator, we're not logged on anyway
if (_comm == null) {
log.warning("Ignoring request to logoff because we're not logged on.");
return true;
}
// if the request is abortable, let's run it past the observers before we act upon it
final boolean[] rejected = new boolean[] { false };
_observers.apply(new ObserverOps.Client(this) {
@Override protected void notify (ClientObserver obs) {
if (!obs.clientWillLogoff(_client)) {
rejected[0] = true;
}
}
});
if (abortable && rejected[0]) {
return false;
}
// ask the communicator to send a logoff message and disconnect from the server
_comm.logoff();
return true;
} | [
"public",
"boolean",
"logoff",
"(",
"boolean",
"abortable",
")",
"{",
"// if we have no communicator, we're not logged on anyway",
"if",
"(",
"_comm",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Ignoring request to logoff because we're not logged on.\"",
")",
"... | Requests that the client log off of the server to which it is connected.
@param abortable If true, the client will call <code>clientWillDisconnect</code> on all of
the client observers and abort the logoff process if any of them return false. If false,
<code>clientWillDisconnect</code> will not be called at all.
@return true if the logoff succeeded, false if it failed due to a disagreeable observer. | [
"Requests",
"that",
"the",
"client",
"log",
"off",
"of",
"the",
"server",
"to",
"which",
"it",
"is",
"connected",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L588-L613 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.prepareStandaloneLogon | public String[] prepareStandaloneLogon ()
{
_standalone = true;
// notify our observers immediately
_observers.apply(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientWillLogon(_client);
}
});
return getBootGroups();
} | java | public String[] prepareStandaloneLogon ()
{
_standalone = true;
// notify our observers immediately
_observers.apply(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientWillLogon(_client);
}
});
return getBootGroups();
} | [
"public",
"String",
"[",
"]",
"prepareStandaloneLogon",
"(",
")",
"{",
"_standalone",
"=",
"true",
";",
"// notify our observers immediately",
"_observers",
".",
"apply",
"(",
"new",
"ObserverOps",
".",
"Session",
"(",
"this",
")",
"{",
"@",
"Override",
"protect... | Prepares the client for a standalone mode logon. Returns the set of bootstrap service groups
that should be supplied to the invocation manager to create our fake bootstrap record. | [
"Prepares",
"the",
"client",
"for",
"a",
"standalone",
"mode",
"logon",
".",
"Returns",
"the",
"set",
"of",
"bootstrap",
"service",
"groups",
"that",
"should",
"be",
"supplied",
"to",
"the",
"invocation",
"manager",
"to",
"create",
"our",
"fake",
"bootstrap",
... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L619-L629 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.standaloneLogon | public void standaloneLogon (BootstrapData data, DObjectManager omgr)
{
if (!_standalone) {
throw new IllegalStateException("Must call prepareStandaloneLogon() first.");
}
gotBootstrap(data, omgr);
} | java | public void standaloneLogon (BootstrapData data, DObjectManager omgr)
{
if (!_standalone) {
throw new IllegalStateException("Must call prepareStandaloneLogon() first.");
}
gotBootstrap(data, omgr);
} | [
"public",
"void",
"standaloneLogon",
"(",
"BootstrapData",
"data",
",",
"DObjectManager",
"omgr",
")",
"{",
"if",
"(",
"!",
"_standalone",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Must call prepareStandaloneLogon() first.\"",
")",
";",
"}",
"gotBoo... | Logs this client on in standalone mode with the faked bootstrap data and shared local
distributed object manager. | [
"Logs",
"this",
"client",
"on",
"in",
"standalone",
"mode",
"with",
"the",
"faked",
"bootstrap",
"data",
"and",
"shared",
"local",
"distributed",
"object",
"manager",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L635-L641 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.standaloneLogoff | public void standaloneLogoff ()
{
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientDidLogoff(_client);
}
});
cleanup(null); // this will set _standalone to false
} | java | public void standaloneLogoff ()
{
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientDidLogoff(_client);
}
});
cleanup(null); // this will set _standalone to false
} | [
"public",
"void",
"standaloneLogoff",
"(",
")",
"{",
"notifyObservers",
"(",
"new",
"ObserverOps",
".",
"Session",
"(",
"this",
")",
"{",
"@",
"Override",
"protected",
"void",
"notify",
"(",
"SessionObserver",
"obs",
")",
"{",
"obs",
".",
"clientDidLogoff",
... | For standalone mode, this notifies observers that the client has logged off and cleans up. | [
"For",
"standalone",
"mode",
"this",
"notifies",
"observers",
"that",
"the",
"client",
"has",
"logged",
"off",
"and",
"cleans",
"up",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L646-L654 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.setOutgoingMessageThrottle | protected synchronized void setOutgoingMessageThrottle (int msgsPerSec)
{
log.info("Updating outgoing message throttle", "msgsPerSec", msgsPerSec);
_outThrottle.reinit(msgsPerSec, 1000L);
_comm.postMessage(new ThrottleUpdatedMessage());
} | java | protected synchronized void setOutgoingMessageThrottle (int msgsPerSec)
{
log.info("Updating outgoing message throttle", "msgsPerSec", msgsPerSec);
_outThrottle.reinit(msgsPerSec, 1000L);
_comm.postMessage(new ThrottleUpdatedMessage());
} | [
"protected",
"synchronized",
"void",
"setOutgoingMessageThrottle",
"(",
"int",
"msgsPerSec",
")",
"{",
"log",
".",
"info",
"(",
"\"Updating outgoing message throttle\"",
",",
"\"msgsPerSec\"",
",",
"msgsPerSec",
")",
";",
"_outThrottle",
".",
"reinit",
"(",
"msgsPerSe... | Configures the outgoing message throttle. This is done when the server informs us that a new
rate is in effect. | [
"Configures",
"the",
"outgoing",
"message",
"throttle",
".",
"This",
"is",
"done",
"when",
"the",
"server",
"informs",
"us",
"that",
"a",
"new",
"rate",
"is",
"in",
"effect",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L744-L749 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.tick | protected void tick ()
{
// if we're not connected, skip it
if (_comm == null) {
return;
}
long now = RunAnywhere.currentTimeMillis();
if (_dcalc != null) {
// if our current calculator is done, clear it out
if (_dcalc.isDone()) {
if (debugLogMessages()) {
log.info("Time offset from server: " + _serverDelta + "ms.");
}
_dcalc = null;
} else if (_dcalc.shouldSendPing()) {
// otherwise, send another ping
PingRequest req = new PingRequest();
_comm.postMessage(req);
_dcalc.sentPing(req);
}
} else if (now - _comm.getLastWrite() > PingRequest.PING_INTERVAL) {
// if we haven't sent anything over the network in a while, we ping the server to let
// it know that we're still alive
_comm.postMessage(new PingRequest());
} else if (now - _lastSync > CLOCK_SYNC_INTERVAL) {
// resync our clock with the server
establishClockDelta(now);
}
} | java | protected void tick ()
{
// if we're not connected, skip it
if (_comm == null) {
return;
}
long now = RunAnywhere.currentTimeMillis();
if (_dcalc != null) {
// if our current calculator is done, clear it out
if (_dcalc.isDone()) {
if (debugLogMessages()) {
log.info("Time offset from server: " + _serverDelta + "ms.");
}
_dcalc = null;
} else if (_dcalc.shouldSendPing()) {
// otherwise, send another ping
PingRequest req = new PingRequest();
_comm.postMessage(req);
_dcalc.sentPing(req);
}
} else if (now - _comm.getLastWrite() > PingRequest.PING_INTERVAL) {
// if we haven't sent anything over the network in a while, we ping the server to let
// it know that we're still alive
_comm.postMessage(new PingRequest());
} else if (now - _lastSync > CLOCK_SYNC_INTERVAL) {
// resync our clock with the server
establishClockDelta(now);
}
} | [
"protected",
"void",
"tick",
"(",
")",
"{",
"// if we're not connected, skip it",
"if",
"(",
"_comm",
"==",
"null",
")",
"{",
"return",
";",
"}",
"long",
"now",
"=",
"RunAnywhere",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"_dcalc",
"!=",
"null",... | Called every five seconds; ensures that we ping the server if we haven't communicated in a
long while and periodically resyncs the client and server clock deltas. | [
"Called",
"every",
"five",
"seconds",
";",
"ensures",
"that",
"we",
"ping",
"the",
"server",
"if",
"we",
"haven",
"t",
"communicated",
"in",
"a",
"long",
"while",
"and",
"periodically",
"resyncs",
"the",
"client",
"and",
"server",
"clock",
"deltas",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L771-L802 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.gotClientObject | protected void gotClientObject (ClientObject clobj)
{
// keep this around
_clobj = clobj;
// let the client know that logon has now fully succeeded
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientDidLogon(_client);
}
});
} | java | protected void gotClientObject (ClientObject clobj)
{
// keep this around
_clobj = clobj;
// let the client know that logon has now fully succeeded
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientDidLogon(_client);
}
});
} | [
"protected",
"void",
"gotClientObject",
"(",
"ClientObject",
"clobj",
")",
"{",
"// keep this around",
"_clobj",
"=",
"clobj",
";",
"// let the client know that logon has now fully succeeded",
"notifyObservers",
"(",
"new",
"ObserverOps",
".",
"Session",
"(",
"this",
")",... | Called by the invocation director when it successfully subscribes to the client object
immediately following logon. | [
"Called",
"by",
"the",
"invocation",
"director",
"when",
"it",
"successfully",
"subscribes",
"to",
"the",
"client",
"object",
"immediately",
"following",
"logon",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L838-L849 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.getClientObjectFailed | protected void getClientObjectFailed (final Exception cause)
{
// pass the buck onto the listeners
notifyObservers(new ObserverOps.Client(this) {
@Override protected void notify (ClientObserver obs) {
obs.clientFailedToLogon(_client, cause);
}
});
} | java | protected void getClientObjectFailed (final Exception cause)
{
// pass the buck onto the listeners
notifyObservers(new ObserverOps.Client(this) {
@Override protected void notify (ClientObserver obs) {
obs.clientFailedToLogon(_client, cause);
}
});
} | [
"protected",
"void",
"getClientObjectFailed",
"(",
"final",
"Exception",
"cause",
")",
"{",
"// pass the buck onto the listeners",
"notifyObservers",
"(",
"new",
"ObserverOps",
".",
"Client",
"(",
"this",
")",
"{",
"@",
"Override",
"protected",
"void",
"notify",
"("... | Called by the invocation director if it fails to subscribe to the client object after logon. | [
"Called",
"by",
"the",
"invocation",
"director",
"if",
"it",
"fails",
"to",
"subscribe",
"to",
"the",
"client",
"object",
"after",
"logon",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L854-L862 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/Client.java | Client.clientObjectDidChange | protected void clientObjectDidChange (ClientObject clobj)
{
_clobj = clobj;
_cloid = _clobj.getOid();
// report to our observers
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientObjectDidChange(_client);
}
});
} | java | protected void clientObjectDidChange (ClientObject clobj)
{
_clobj = clobj;
_cloid = _clobj.getOid();
// report to our observers
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientObjectDidChange(_client);
}
});
} | [
"protected",
"void",
"clientObjectDidChange",
"(",
"ClientObject",
"clobj",
")",
"{",
"_clobj",
"=",
"clobj",
";",
"_cloid",
"=",
"_clobj",
".",
"getOid",
"(",
")",
";",
"// report to our observers",
"notifyObservers",
"(",
"new",
"ObserverOps",
".",
"Session",
... | Called by the invocation director when it discovers that the client object has changed. | [
"Called",
"by",
"the",
"invocation",
"director",
"when",
"it",
"discovers",
"that",
"the",
"client",
"object",
"has",
"changed",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L867-L878 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcField.java | MarcField.getSubfield | public Deque<Subfield> getSubfield(String subfieldId) {
return subfields.stream()
.filter(subfield -> subfield.getId().equals(subfieldId))
.collect(Collectors.toCollection(LinkedList::new));
} | java | public Deque<Subfield> getSubfield(String subfieldId) {
return subfields.stream()
.filter(subfield -> subfield.getId().equals(subfieldId))
.collect(Collectors.toCollection(LinkedList::new));
} | [
"public",
"Deque",
"<",
"Subfield",
">",
"getSubfield",
"(",
"String",
"subfieldId",
")",
"{",
"return",
"subfields",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"subfield",
"->",
"subfield",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"subfieldId",
")"... | Return all subfields of a given subfield ID. Multiple occurences may occur.
@param subfieldId subfield ID
@return list of subfields | [
"Return",
"all",
"subfields",
"of",
"a",
"given",
"subfield",
"ID",
".",
"Multiple",
"occurences",
"may",
"occur",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcField.java#L151-L155 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcField.java | MarcField.matchValue | public MarcField matchValue(Pattern pattern) {
if (value != null && pattern.matcher(value).matches()) {
return this;
}
for (Subfield subfield : subfields) {
if (pattern.matcher(subfield.getValue()).matches()) {
return this;
}
}
return null;
} | java | public MarcField matchValue(Pattern pattern) {
if (value != null && pattern.matcher(value).matches()) {
return this;
}
for (Subfield subfield : subfields) {
if (pattern.matcher(subfield.getValue()).matches()) {
return this;
}
}
return null;
} | [
"public",
"MarcField",
"matchValue",
"(",
"Pattern",
"pattern",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"pattern",
".",
"matcher",
"(",
"value",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"for",
"(",
"Subfield",
"s... | Search for fields that match a pattern.
@param pattern the pattern to match
@return thhis MARC field if pattern matches, or null if not | [
"Search",
"for",
"fields",
"that",
"match",
"a",
"pattern",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcField.java#L277-L287 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcField.java | MarcField.toTagIndicatorKey | public String toTagIndicatorKey() {
return (tag == null ? EMPTY_STRING : tag) + KEY_DELIMITER + (indicator == null ? EMPTY_STRING : indicator);
} | java | public String toTagIndicatorKey() {
return (tag == null ? EMPTY_STRING : tag) + KEY_DELIMITER + (indicator == null ? EMPTY_STRING : indicator);
} | [
"public",
"String",
"toTagIndicatorKey",
"(",
")",
"{",
"return",
"(",
"tag",
"==",
"null",
"?",
"EMPTY_STRING",
":",
"tag",
")",
"+",
"KEY_DELIMITER",
"+",
"(",
"indicator",
"==",
"null",
"?",
"EMPTY_STRING",
":",
"indicator",
")",
";",
"}"
] | A MARC field can be denoted by a key, independent of values.
This key is a string, consisting of tag and indicator delimited by a dollar sign.
@return the tag/indicator-based key of this MARC field | [
"A",
"MARC",
"field",
"can",
"be",
"denoted",
"by",
"a",
"key",
"independent",
"of",
"values",
".",
"This",
"key",
"is",
"a",
"string",
"consisting",
"of",
"tag",
"and",
"indicator",
"delimited",
"by",
"a",
"dollar",
"sign",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcField.java#L305-L307 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcField.java | MarcField.toKey | public String toKey() {
return (tag == null ? EMPTY_STRING : tag) + KEY_DELIMITER + (indicator == null ? EMPTY_STRING : indicator) +
KEY_DELIMITER + subfieldIds;
} | java | public String toKey() {
return (tag == null ? EMPTY_STRING : tag) + KEY_DELIMITER + (indicator == null ? EMPTY_STRING : indicator) +
KEY_DELIMITER + subfieldIds;
} | [
"public",
"String",
"toKey",
"(",
")",
"{",
"return",
"(",
"tag",
"==",
"null",
"?",
"EMPTY_STRING",
":",
"tag",
")",
"+",
"KEY_DELIMITER",
"+",
"(",
"indicator",
"==",
"null",
"?",
"EMPTY_STRING",
":",
"indicator",
")",
"+",
"KEY_DELIMITER",
"+",
"subfi... | A MARC field can be denoted by a key, independent of values.
This key is a string, consisting of tag, indicator, subfield IDs, delimited by a dollar sign.
@return the key of this MARC field | [
"A",
"MARC",
"field",
"can",
"be",
"denoted",
"by",
"a",
"key",
"independent",
"of",
"values",
".",
"This",
"key",
"is",
"a",
"string",
"consisting",
"of",
"tag",
"indicator",
"subfield",
"IDs",
"delimited",
"by",
"a",
"dollar",
"sign",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcField.java#L323-L326 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/BodyManager.java | BodyManager.updateOccupantStatus | public void updateOccupantStatus (BodyObject body, final byte status)
{
// no need to NOOP
if (body.status != status) {
// update the status in their body object
body.setStatus(status);
body.getLocal(BodyLocal.class).statusTime = System.currentTimeMillis();
}
updateOccupantInfo(body, new OccupantInfo.Updater<OccupantInfo>() {
public boolean update (OccupantInfo info) {
if (info.status == status) {
return false;
}
info.status = status;
return true;
}
});
} | java | public void updateOccupantStatus (BodyObject body, final byte status)
{
// no need to NOOP
if (body.status != status) {
// update the status in their body object
body.setStatus(status);
body.getLocal(BodyLocal.class).statusTime = System.currentTimeMillis();
}
updateOccupantInfo(body, new OccupantInfo.Updater<OccupantInfo>() {
public boolean update (OccupantInfo info) {
if (info.status == status) {
return false;
}
info.status = status;
return true;
}
});
} | [
"public",
"void",
"updateOccupantStatus",
"(",
"BodyObject",
"body",
",",
"final",
"byte",
"status",
")",
"{",
"// no need to NOOP",
"if",
"(",
"body",
".",
"status",
"!=",
"status",
")",
"{",
"// update the status in their body object",
"body",
".",
"setStatus",
... | Updates the connection status for the given body object's occupant info in the specified
location. | [
"Updates",
"the",
"connection",
"status",
"for",
"the",
"given",
"body",
"object",
"s",
"occupant",
"info",
"in",
"the",
"specified",
"location",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/BodyManager.java#L68-L86 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/BodyManager.java | BodyManager.setIdle | public void setIdle (ClientObject caller, boolean idle)
{
BodyObject bobj = _locator.forClient(caller);
// determine the body's proposed new status
byte nstatus = (idle) ? OccupantInfo.IDLE : OccupantInfo.ACTIVE;
if (bobj == null || bobj.status == nstatus) {
return; // ignore NOOP attempts
}
// update their status!
log.debug("Setting user idle state", "user", bobj.username, "status", nstatus);
updateOccupantStatus(bobj, nstatus);
} | java | public void setIdle (ClientObject caller, boolean idle)
{
BodyObject bobj = _locator.forClient(caller);
// determine the body's proposed new status
byte nstatus = (idle) ? OccupantInfo.IDLE : OccupantInfo.ACTIVE;
if (bobj == null || bobj.status == nstatus) {
return; // ignore NOOP attempts
}
// update their status!
log.debug("Setting user idle state", "user", bobj.username, "status", nstatus);
updateOccupantStatus(bobj, nstatus);
} | [
"public",
"void",
"setIdle",
"(",
"ClientObject",
"caller",
",",
"boolean",
"idle",
")",
"{",
"BodyObject",
"bobj",
"=",
"_locator",
".",
"forClient",
"(",
"caller",
")",
";",
"// determine the body's proposed new status",
"byte",
"nstatus",
"=",
"(",
"idle",
")... | from interface BodyProvider | [
"from",
"interface",
"BodyProvider"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/BodyManager.java#L89-L102 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/ReportingInvoker.java | ReportingInvoker.getStats | public Stats getStats (boolean snapshot)
{
synchronized (this) {
if (snapshot) {
_recent = _current;
_current = new Stats();
_current.maxQueueSize = _queue.size();
}
return _recent;
}
} | java | public Stats getStats (boolean snapshot)
{
synchronized (this) {
if (snapshot) {
_recent = _current;
_current = new Stats();
_current.maxQueueSize = _queue.size();
}
return _recent;
}
} | [
"public",
"Stats",
"getStats",
"(",
"boolean",
"snapshot",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"snapshot",
")",
"{",
"_recent",
"=",
"_current",
";",
"_current",
"=",
"new",
"Stats",
"(",
")",
";",
"_current",
".",
"maxQueueSize",... | Returns a recent snapshot of runtime statistics tracked by the invoker.
@param snapshot if true, the current stats will be snapshotted and reset and the new
snapshot will be returned. If false, the previous snapshot will be returned. If no snapshot
has ever been taken, the current stats that have been accumulting since the JVM start will
be returned. | [
"Returns",
"a",
"recent",
"snapshot",
"of",
"runtime",
"statistics",
"tracked",
"by",
"the",
"invoker",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ReportingInvoker.java#L62-L72 | train |
threerings/narya | core/src/main/java/com/threerings/util/Resulting.java | Resulting.requestProcessed | public final void requestProcessed (Object result)
{
@SuppressWarnings("unchecked") T casted = (T)result;
requestCompleted(casted);
} | java | public final void requestProcessed (Object result)
{
@SuppressWarnings("unchecked") T casted = (T)result;
requestCompleted(casted);
} | [
"public",
"final",
"void",
"requestProcessed",
"(",
"Object",
"result",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"casted",
"=",
"(",
"T",
")",
"result",
";",
"requestCompleted",
"(",
"casted",
")",
";",
"}"
] | from InvocationService.ResultListener | [
"from",
"InvocationService",
".",
"ResultListener"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/util/Resulting.java#L202-L206 | train |
threerings/narya | core/src/main/java/com/threerings/util/Resulting.java | Resulting.requestFailed | public void requestFailed (Exception cause)
{
if (_chain != null) {
_chain.requestFailed(cause);
} else if (_invChain != null) {
_invChain.requestFailed((cause instanceof InvocationException)
? cause.getMessage()
: InvocationCodes.INTERNAL_ERROR);
} else {
Object[] logArgs = MoreObjects.firstNonNull(_logArgs, ArrayUtil.EMPTY_OBJECT);
Object[] args;
if (cause instanceof InvocationException) {
args = new Object[logArgs.length + 4];
args[args.length - 2] = "error";
args[args.length - 1] = cause.getMessage();
} else {
args = new Object[logArgs.length + 3];
args[args.length - 1] = cause;
}
args[0] = "Resulting";
args[1] = this;
System.arraycopy(logArgs, 0, args, 2, logArgs.length);
MoreObjects.firstNonNull(_log, log).warning("Request failed", args);
}
} | java | public void requestFailed (Exception cause)
{
if (_chain != null) {
_chain.requestFailed(cause);
} else if (_invChain != null) {
_invChain.requestFailed((cause instanceof InvocationException)
? cause.getMessage()
: InvocationCodes.INTERNAL_ERROR);
} else {
Object[] logArgs = MoreObjects.firstNonNull(_logArgs, ArrayUtil.EMPTY_OBJECT);
Object[] args;
if (cause instanceof InvocationException) {
args = new Object[logArgs.length + 4];
args[args.length - 2] = "error";
args[args.length - 1] = cause.getMessage();
} else {
args = new Object[logArgs.length + 3];
args[args.length - 1] = cause;
}
args[0] = "Resulting";
args[1] = this;
System.arraycopy(logArgs, 0, args, 2, logArgs.length);
MoreObjects.firstNonNull(_log, log).warning("Request failed", args);
}
} | [
"public",
"void",
"requestFailed",
"(",
"Exception",
"cause",
")",
"{",
"if",
"(",
"_chain",
"!=",
"null",
")",
"{",
"_chain",
".",
"requestFailed",
"(",
"cause",
")",
";",
"}",
"else",
"if",
"(",
"_invChain",
"!=",
"null",
")",
"{",
"_invChain",
".",
... | Override this to handle a request failed in your own way. | [
"Override",
"this",
"to",
"handle",
"a",
"request",
"failed",
"in",
"your",
"own",
"way",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/util/Resulting.java#L211-L238 | train |
threerings/narya | core/src/main/java/com/threerings/util/Resulting.java | Resulting.requestCompleted | public void requestCompleted (T result)
{
if (_chain != null) {
_chain.requestCompleted(result);
} else if (_invChain instanceof InvocationService.ResultListener) {
((InvocationService.ResultListener)_invChain).requestProcessed(result);
} else if (_invChain instanceof InvocationService.ConfirmListener) {
((InvocationService.ConfirmListener)_invChain).requestProcessed();
}
} | java | public void requestCompleted (T result)
{
if (_chain != null) {
_chain.requestCompleted(result);
} else if (_invChain instanceof InvocationService.ResultListener) {
((InvocationService.ResultListener)_invChain).requestProcessed(result);
} else if (_invChain instanceof InvocationService.ConfirmListener) {
((InvocationService.ConfirmListener)_invChain).requestProcessed();
}
} | [
"public",
"void",
"requestCompleted",
"(",
"T",
"result",
")",
"{",
"if",
"(",
"_chain",
"!=",
"null",
")",
"{",
"_chain",
".",
"requestCompleted",
"(",
"result",
")",
";",
"}",
"else",
"if",
"(",
"_invChain",
"instanceof",
"InvocationService",
".",
"Resul... | Override this to handle a request completion in your own way. | [
"Override",
"this",
"to",
"handle",
"a",
"request",
"completion",
"in",
"your",
"own",
"way",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/util/Resulting.java#L243-L254 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/client/PlaceController.java | PlaceController.init | public void init (CrowdContext ctx, PlaceConfig config)
{
// keep these around
_ctx = ctx;
_config = config;
// create our user interface
_view = createPlaceView(_ctx);
// initialize our delegates
applyToDelegates(new DelegateOp(PlaceControllerDelegate.class) {
@Override
public void apply (PlaceControllerDelegate delegate) {
delegate.init(_ctx, _config);
}
});
// let the derived classes do any initialization stuff
didInit();
} | java | public void init (CrowdContext ctx, PlaceConfig config)
{
// keep these around
_ctx = ctx;
_config = config;
// create our user interface
_view = createPlaceView(_ctx);
// initialize our delegates
applyToDelegates(new DelegateOp(PlaceControllerDelegate.class) {
@Override
public void apply (PlaceControllerDelegate delegate) {
delegate.init(_ctx, _config);
}
});
// let the derived classes do any initialization stuff
didInit();
} | [
"public",
"void",
"init",
"(",
"CrowdContext",
"ctx",
",",
"PlaceConfig",
"config",
")",
"{",
"// keep these around",
"_ctx",
"=",
"ctx",
";",
"_config",
"=",
"config",
";",
"// create our user interface",
"_view",
"=",
"createPlaceView",
"(",
"_ctx",
")",
";",
... | Initializes this place controller with a reference to the context that they can use to
access client services and to the configuration record for this place. The controller
should create as much of its user interface that it can without having access to the place
object because this will be invoked in parallel with the fetching of the place object. When
the place object is obtained, the controller will be notified and it can then finish the
user interface configuration and put the user interface into operation.
@param ctx the client context.
@param config the place configuration for this place. | [
"Initializes",
"this",
"place",
"controller",
"with",
"a",
"reference",
"to",
"the",
"context",
"that",
"they",
"can",
"use",
"to",
"access",
"client",
"services",
"and",
"to",
"the",
"configuration",
"record",
"for",
"this",
"place",
".",
"The",
"controller",... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/PlaceController.java#L73-L92 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/client/PlaceController.java | PlaceController.addDelegate | protected void addDelegate (PlaceControllerDelegate delegate)
{
if (_delegates == null) {
_delegates = Lists.newArrayList();
}
_delegates.add(delegate);
} | java | protected void addDelegate (PlaceControllerDelegate delegate)
{
if (_delegates == null) {
_delegates = Lists.newArrayList();
}
_delegates.add(delegate);
} | [
"protected",
"void",
"addDelegate",
"(",
"PlaceControllerDelegate",
"delegate",
")",
"{",
"if",
"(",
"_delegates",
"==",
"null",
")",
"{",
"_delegates",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"}",
"_delegates",
".",
"add",
"(",
"delegate",
")",
... | Adds the supplied delegate to the list for this controller. | [
"Adds",
"the",
"supplied",
"delegate",
"to",
"the",
"list",
"for",
"this",
"controller",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/PlaceController.java#L238-L244 | train |
threerings/narya | core/src/main/java/com/threerings/admin/client/ConfigObjectManager.java | ConfigObjectManager.gotConfigInfo | public void gotConfigInfo (String[] keys, int[] oids)
{
_csubscribers = new ConfigObjectSubscriber[keys.length];
for (int ii = 0; ii < keys.length; ii++) {
_csubscribers[ii] = new ConfigObjectSubscriber();
_csubscribers[ii].subscribeConfig(keys[ii], oids[ii]);
}
} | java | public void gotConfigInfo (String[] keys, int[] oids)
{
_csubscribers = new ConfigObjectSubscriber[keys.length];
for (int ii = 0; ii < keys.length; ii++) {
_csubscribers[ii] = new ConfigObjectSubscriber();
_csubscribers[ii].subscribeConfig(keys[ii], oids[ii]);
}
} | [
"public",
"void",
"gotConfigInfo",
"(",
"String",
"[",
"]",
"keys",
",",
"int",
"[",
"]",
"oids",
")",
"{",
"_csubscribers",
"=",
"new",
"ConfigObjectSubscriber",
"[",
"keys",
".",
"length",
"]",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<"... | documentation inherited from interface AdminService.ConfigInfoListener | [
"documentation",
"inherited",
"from",
"interface",
"AdminService",
".",
"ConfigInfoListener"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/client/ConfigObjectManager.java#L78-L85 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcRecord.java | MarcRecord.getFields | public List<MarcField> getFields(String tag) {
return marcFields.stream().filter(marcField -> marcField.getTag().equals(tag))
.collect(Collectors.toList());
} | java | public List<MarcField> getFields(String tag) {
return marcFields.stream().filter(marcField -> marcField.getTag().equals(tag))
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"MarcField",
">",
"getFields",
"(",
"String",
"tag",
")",
"{",
"return",
"marcFields",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"marcField",
"->",
"marcField",
".",
"getTag",
"(",
")",
".",
"equals",
"(",
"tag",
")",
")",
"... | Return the MARC fields of this record with a given tag.
@param tag the MARC tag
@return the MARC field list matching the given tag. | [
"Return",
"the",
"MARC",
"fields",
"of",
"this",
"record",
"with",
"a",
"given",
"tag",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcRecord.java#L121-L124 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcRecord.java | MarcRecord.filterKey | public List<MarcField> filterKey(Pattern pattern) {
return marcFields.stream()
.map(field -> field.matchKey(pattern))
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | java | public List<MarcField> filterKey(Pattern pattern) {
return marcFields.stream()
.map(field -> field.matchKey(pattern))
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"MarcField",
">",
"filterKey",
"(",
"Pattern",
"pattern",
")",
"{",
"return",
"marcFields",
".",
"stream",
"(",
")",
".",
"map",
"(",
"field",
"->",
"field",
".",
"matchKey",
"(",
"pattern",
")",
")",
".",
"filter",
"(",
"Objects... | Return a list of MARC fields of this record where key pattern matches were found.
@param pattern the pattern
@return a list of MARC fields | [
"Return",
"a",
"list",
"of",
"MARC",
"fields",
"of",
"this",
"record",
"where",
"key",
"pattern",
"matches",
"were",
"found",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcRecord.java#L132-L137 | train |
xbib/marc | src/main/java/org/xbib/marc/MarcRecord.java | MarcRecord.filterValue | public List<MarcField> filterValue(Pattern pattern) {
return marcFields.stream().map(field ->
field.matchValue(pattern)).filter(Objects::nonNull).collect(Collectors.toList());
} | java | public List<MarcField> filterValue(Pattern pattern) {
return marcFields.stream().map(field ->
field.matchValue(pattern)).filter(Objects::nonNull).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"MarcField",
">",
"filterValue",
"(",
"Pattern",
"pattern",
")",
"{",
"return",
"marcFields",
".",
"stream",
"(",
")",
".",
"map",
"(",
"field",
"->",
"field",
".",
"matchValue",
"(",
"pattern",
")",
")",
".",
"filter",
"(",
"Obj... | Return a list of MARC fields of this record where pattern matches were found.
@param pattern the pattern
@return a list of MARC fields | [
"Return",
"a",
"list",
"of",
"MARC",
"fields",
"of",
"this",
"record",
"where",
"pattern",
"matches",
"were",
"found",
"."
] | d8426fcfc686507cab59b3d8181b08f83718418c | https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/MarcRecord.java#L145-L148 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/SessionFactory.java | SessionFactory.newSessionFactory | public static SessionFactory newSessionFactory (
final Class<? extends Credentials> credsClass,
final Class<? extends PresentsSession> sessionClass,
final Class<? extends Name> nameClass,
final Class<? extends ClientResolver> resolverClass)
{
return new SessionFactory() {
@Override public Class<? extends PresentsSession> getSessionClass (AuthRequest areq) {
return credsClass.isInstance(areq.getCredentials()) ? sessionClass : null;
}
@Override
public Class <? extends ClientResolver> getClientResolverClass (Name username) {
return nameClass.isInstance(username) ? resolverClass : null;
}
};
} | java | public static SessionFactory newSessionFactory (
final Class<? extends Credentials> credsClass,
final Class<? extends PresentsSession> sessionClass,
final Class<? extends Name> nameClass,
final Class<? extends ClientResolver> resolverClass)
{
return new SessionFactory() {
@Override public Class<? extends PresentsSession> getSessionClass (AuthRequest areq) {
return credsClass.isInstance(areq.getCredentials()) ? sessionClass : null;
}
@Override
public Class <? extends ClientResolver> getClientResolverClass (Name username) {
return nameClass.isInstance(username) ? resolverClass : null;
}
};
} | [
"public",
"static",
"SessionFactory",
"newSessionFactory",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Credentials",
">",
"credsClass",
",",
"final",
"Class",
"<",
"?",
"extends",
"PresentsSession",
">",
"sessionClass",
",",
"final",
"Class",
"<",
"?",
"extends... | Creates a session factory that handles clients with the supplied credentials and
authentication name. | [
"Creates",
"a",
"session",
"factory",
"that",
"handles",
"clients",
"with",
"the",
"supplied",
"credentials",
"and",
"authentication",
"name",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/SessionFactory.java#L49-L64 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.init | public void init (DObjectManager omgr, final int cloid, Client client)
{
// sanity check
if (_clobj != null) {
log.warning("Zoiks, client object around during invmgr init!");
cleanup();
}
// keep these for later
_omgr = omgr;
_client = client;
// add ourselves as a subscriber to the client object
_omgr.subscribeToObject(cloid, new Subscriber<ClientObject>() {
public void objectAvailable (ClientObject clobj) {
// add ourselves as an event listener
clobj.addListener(InvocationDirector.this);
// keep a handle on this bad boy
_clobj = clobj;
// assign a mapping to already registered receivers
assignReceiverIds();
// let the client know that we're ready to go now that we've got our subscription
// to the client object
_client.gotClientObject(_clobj);
}
public void requestFailed (int oid, ObjectAccessException cause) {
// aiya! we were unable to subscribe to the client object. we're hosed!
log.warning("Invocation director unable to subscribe to client object",
"cloid", cloid, "cause", cause + "]!");
_client.getClientObjectFailed(cause);
}
});
} | java | public void init (DObjectManager omgr, final int cloid, Client client)
{
// sanity check
if (_clobj != null) {
log.warning("Zoiks, client object around during invmgr init!");
cleanup();
}
// keep these for later
_omgr = omgr;
_client = client;
// add ourselves as a subscriber to the client object
_omgr.subscribeToObject(cloid, new Subscriber<ClientObject>() {
public void objectAvailable (ClientObject clobj) {
// add ourselves as an event listener
clobj.addListener(InvocationDirector.this);
// keep a handle on this bad boy
_clobj = clobj;
// assign a mapping to already registered receivers
assignReceiverIds();
// let the client know that we're ready to go now that we've got our subscription
// to the client object
_client.gotClientObject(_clobj);
}
public void requestFailed (int oid, ObjectAccessException cause) {
// aiya! we were unable to subscribe to the client object. we're hosed!
log.warning("Invocation director unable to subscribe to client object",
"cloid", cloid, "cause", cause + "]!");
_client.getClientObjectFailed(cause);
}
});
} | [
"public",
"void",
"init",
"(",
"DObjectManager",
"omgr",
",",
"final",
"int",
"cloid",
",",
"Client",
"client",
")",
"{",
"// sanity check",
"if",
"(",
"_clobj",
"!=",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Zoiks, client object around during invmgr ini... | Initializes the invocation director. This is called when the client establishes a connection
with the server.
@param omgr the distributed object manager via which the invocation manager will send and
receive events.
@param cloid the oid of the object on which invocation notifications as well as invocation
responses will be received.
@param client a reference to the client for whom we're doing our business. | [
"Initializes",
"the",
"invocation",
"director",
".",
"This",
"is",
"called",
"when",
"the",
"client",
"establishes",
"a",
"connection",
"with",
"the",
"server",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L65-L101 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.registerReceiver | public void registerReceiver (InvocationDecoder decoder)
{
// add the receiver to the list
_reclist.add(decoder);
// if we're already online, assign a receiver id to this decoder
if (_clobj != null) {
assignReceiverId(decoder);
}
} | java | public void registerReceiver (InvocationDecoder decoder)
{
// add the receiver to the list
_reclist.add(decoder);
// if we're already online, assign a receiver id to this decoder
if (_clobj != null) {
assignReceiverId(decoder);
}
} | [
"public",
"void",
"registerReceiver",
"(",
"InvocationDecoder",
"decoder",
")",
"{",
"// add the receiver to the list",
"_reclist",
".",
"add",
"(",
"decoder",
")",
";",
"// if we're already online, assign a receiver id to this decoder",
"if",
"(",
"_clobj",
"!=",
"null",
... | Registers an invocation notification receiver by way of its notification event decoder. | [
"Registers",
"an",
"invocation",
"notification",
"receiver",
"by",
"way",
"of",
"its",
"notification",
"event",
"decoder",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L131-L140 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.unregisterReceiver | public void unregisterReceiver (String receiverCode)
{
// remove the receiver from the list
for (Iterator<InvocationDecoder> iter = _reclist.iterator(); iter.hasNext(); ) {
InvocationDecoder decoder = iter.next();
if (decoder.getReceiverCode().equals(receiverCode)) {
iter.remove();
}
}
// if we're logged on, clear out any receiver id mapping
if (_clobj != null) {
Registration rreg = _clobj.receivers.get(receiverCode);
if (rreg == null) {
log.warning("Receiver unregistered for which we have no id to code mapping",
"code", receiverCode);
} else {
_receivers.remove(rreg.receiverId);
// Log.info("Cleared receiver " + StringUtil.shortClassName(decoder) +
// " " + rreg + ".");
}
_clobj.removeFromReceivers(receiverCode);
}
} | java | public void unregisterReceiver (String receiverCode)
{
// remove the receiver from the list
for (Iterator<InvocationDecoder> iter = _reclist.iterator(); iter.hasNext(); ) {
InvocationDecoder decoder = iter.next();
if (decoder.getReceiverCode().equals(receiverCode)) {
iter.remove();
}
}
// if we're logged on, clear out any receiver id mapping
if (_clobj != null) {
Registration rreg = _clobj.receivers.get(receiverCode);
if (rreg == null) {
log.warning("Receiver unregistered for which we have no id to code mapping",
"code", receiverCode);
} else {
_receivers.remove(rreg.receiverId);
// Log.info("Cleared receiver " + StringUtil.shortClassName(decoder) +
// " " + rreg + ".");
}
_clobj.removeFromReceivers(receiverCode);
}
} | [
"public",
"void",
"unregisterReceiver",
"(",
"String",
"receiverCode",
")",
"{",
"// remove the receiver from the list",
"for",
"(",
"Iterator",
"<",
"InvocationDecoder",
">",
"iter",
"=",
"_reclist",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
... | Removes a receiver registration. | [
"Removes",
"a",
"receiver",
"registration",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L145-L168 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.assignReceiverIds | protected void assignReceiverIds ()
{
// pack all the events into a single transaction
_clobj.startTransaction();
try {
// clear out our previous registrations
_clobj.setReceivers(new DSet<Registration>());
for (InvocationDecoder decoder : _reclist) {
assignReceiverId(decoder);
}
} finally {
_clobj.commitTransaction();
}
} | java | protected void assignReceiverIds ()
{
// pack all the events into a single transaction
_clobj.startTransaction();
try {
// clear out our previous registrations
_clobj.setReceivers(new DSet<Registration>());
for (InvocationDecoder decoder : _reclist) {
assignReceiverId(decoder);
}
} finally {
_clobj.commitTransaction();
}
} | [
"protected",
"void",
"assignReceiverIds",
"(",
")",
"{",
"// pack all the events into a single transaction",
"_clobj",
".",
"startTransaction",
"(",
")",
";",
"try",
"{",
"// clear out our previous registrations",
"_clobj",
".",
"setReceivers",
"(",
"new",
"DSet",
"<",
... | Called when we log on; generates mappings for all receivers registered prior to logon. | [
"Called",
"when",
"we",
"log",
"on",
";",
"generates",
"mappings",
"for",
"all",
"receivers",
"registered",
"prior",
"to",
"logon",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L173-L187 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.eventReceived | public void eventReceived (DEvent event)
{
if (event instanceof InvocationResponseEvent) {
InvocationResponseEvent ire = (InvocationResponseEvent)event;
handleInvocationResponse(ire.getRequestId(), ire.getMethodId(), ire.getArgs());
} else if (event instanceof InvocationNotificationEvent) {
InvocationNotificationEvent ine = (InvocationNotificationEvent)event;
handleInvocationNotification(ine.getReceiverId(), ine.getMethodId(), ine.getArgs());
} else if (event instanceof MessageEvent) {
MessageEvent mevt = (MessageEvent)event;
if (mevt.getName().equals(ClientObject.CLOBJ_CHANGED)) {
handleClientObjectChanged(((Integer)mevt.getArgs()[0]).intValue());
}
}
} | java | public void eventReceived (DEvent event)
{
if (event instanceof InvocationResponseEvent) {
InvocationResponseEvent ire = (InvocationResponseEvent)event;
handleInvocationResponse(ire.getRequestId(), ire.getMethodId(), ire.getArgs());
} else if (event instanceof InvocationNotificationEvent) {
InvocationNotificationEvent ine = (InvocationNotificationEvent)event;
handleInvocationNotification(ine.getReceiverId(), ine.getMethodId(), ine.getArgs());
} else if (event instanceof MessageEvent) {
MessageEvent mevt = (MessageEvent)event;
if (mevt.getName().equals(ClientObject.CLOBJ_CHANGED)) {
handleClientObjectChanged(((Integer)mevt.getArgs()[0]).intValue());
}
}
} | [
"public",
"void",
"eventReceived",
"(",
"DEvent",
"event",
")",
"{",
"if",
"(",
"event",
"instanceof",
"InvocationResponseEvent",
")",
"{",
"InvocationResponseEvent",
"ire",
"=",
"(",
"InvocationResponseEvent",
")",
"event",
";",
"handleInvocationResponse",
"(",
"ir... | Process notification and response events arriving on user object. | [
"Process",
"notification",
"and",
"response",
"events",
"arriving",
"on",
"user",
"object",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L257-L273 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.handleInvocationResponse | protected void handleInvocationResponse (int reqId, int methodId, Object[] args)
{
// look up the invocation marshaller registered for that response
ListenerMarshaller listener = _listeners.remove(reqId);
if (listener == null) {
log.warning("Received invocation response for which we have no registered listener. " +
"It is possible that this listener was flushed because the response did " +
"not arrive within " + _listenerMaxAge + " milliseconds.",
"reqId", reqId, "methId", methodId, "args", args);
return;
}
// log.info("Dispatching invocation response", "listener", listener,
// "methId", methodId, "args", args);
// dispatch the response
try {
listener.dispatchResponse(methodId, args);
} catch (Throwable t) {
log.warning("Invocation response listener choked", "listener", listener,
"methId", methodId, "args", args, t);
}
// flush expired listeners periodically
long now = System.currentTimeMillis();
if (now - _lastFlushTime > LISTENER_FLUSH_INTERVAL) {
_lastFlushTime = now;
flushListeners(now);
}
} | java | protected void handleInvocationResponse (int reqId, int methodId, Object[] args)
{
// look up the invocation marshaller registered for that response
ListenerMarshaller listener = _listeners.remove(reqId);
if (listener == null) {
log.warning("Received invocation response for which we have no registered listener. " +
"It is possible that this listener was flushed because the response did " +
"not arrive within " + _listenerMaxAge + " milliseconds.",
"reqId", reqId, "methId", methodId, "args", args);
return;
}
// log.info("Dispatching invocation response", "listener", listener,
// "methId", methodId, "args", args);
// dispatch the response
try {
listener.dispatchResponse(methodId, args);
} catch (Throwable t) {
log.warning("Invocation response listener choked", "listener", listener,
"methId", methodId, "args", args, t);
}
// flush expired listeners periodically
long now = System.currentTimeMillis();
if (now - _lastFlushTime > LISTENER_FLUSH_INTERVAL) {
_lastFlushTime = now;
flushListeners(now);
}
} | [
"protected",
"void",
"handleInvocationResponse",
"(",
"int",
"reqId",
",",
"int",
"methodId",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"// look up the invocation marshaller registered for that response",
"ListenerMarshaller",
"listener",
"=",
"_listeners",
".",
"remove"... | Dispatches an invocation response. | [
"Dispatches",
"an",
"invocation",
"response",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L278-L307 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.handleInvocationNotification | protected void handleInvocationNotification (int receiverId, int methodId, Object[] args)
{
// look up the decoder registered for this receiver
InvocationDecoder decoder = _receivers.get(receiverId);
if (decoder == null) {
log.warning("Received notification for which we have no registered receiver",
"recvId", receiverId, "methodId", methodId, "args", args);
return;
}
// log.info("Dispatching invocation notification", "receiver", decoder.receiver,
// "methodId", methodId, "args", args);
try {
decoder.dispatchNotification(methodId, args);
} catch (Throwable t) {
log.warning("Invocation notification receiver choked", "receiver", decoder.receiver,
"methId", methodId, "args", args, t);
}
} | java | protected void handleInvocationNotification (int receiverId, int methodId, Object[] args)
{
// look up the decoder registered for this receiver
InvocationDecoder decoder = _receivers.get(receiverId);
if (decoder == null) {
log.warning("Received notification for which we have no registered receiver",
"recvId", receiverId, "methodId", methodId, "args", args);
return;
}
// log.info("Dispatching invocation notification", "receiver", decoder.receiver,
// "methodId", methodId, "args", args);
try {
decoder.dispatchNotification(methodId, args);
} catch (Throwable t) {
log.warning("Invocation notification receiver choked", "receiver", decoder.receiver,
"methId", methodId, "args", args, t);
}
} | [
"protected",
"void",
"handleInvocationNotification",
"(",
"int",
"receiverId",
",",
"int",
"methodId",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"// look up the decoder registered for this receiver",
"InvocationDecoder",
"decoder",
"=",
"_receivers",
".",
"get",
"(",
... | Dispatches an invocation notification. | [
"Dispatches",
"an",
"invocation",
"notification",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L312-L331 | train |
threerings/narya | core/src/main/java/com/threerings/presents/client/InvocationDirector.java | InvocationDirector.handleClientObjectChanged | protected void handleClientObjectChanged (int newCloid)
{
// subscribe to the new client object
_omgr.subscribeToObject(newCloid, new Subscriber<ClientObject>() {
public void objectAvailable (ClientObject clobj) {
// grab a reference to our old receiver registrations
DSet<Registration> receivers = _clobj.receivers;
// replace the client object
_clobj = clobj;
// add ourselves as an event listener
_clobj.addListener(InvocationDirector.this);
// reregister our receivers
_clobj.startTransaction();
try {
_clobj.setReceivers(new DSet<Registration>());
for (Registration reg : receivers) {
_clobj.addToReceivers(reg);
}
} finally {
_clobj.commitTransaction();
}
// and report the switcheroo back to the client
_client.clientObjectDidChange(_clobj);
}
public void requestFailed (int oid, ObjectAccessException cause) {
log.warning("Aiya! Unable to subscribe to changed client object", "cloid", oid,
"cause", cause);
}
});
} | java | protected void handleClientObjectChanged (int newCloid)
{
// subscribe to the new client object
_omgr.subscribeToObject(newCloid, new Subscriber<ClientObject>() {
public void objectAvailable (ClientObject clobj) {
// grab a reference to our old receiver registrations
DSet<Registration> receivers = _clobj.receivers;
// replace the client object
_clobj = clobj;
// add ourselves as an event listener
_clobj.addListener(InvocationDirector.this);
// reregister our receivers
_clobj.startTransaction();
try {
_clobj.setReceivers(new DSet<Registration>());
for (Registration reg : receivers) {
_clobj.addToReceivers(reg);
}
} finally {
_clobj.commitTransaction();
}
// and report the switcheroo back to the client
_client.clientObjectDidChange(_clobj);
}
public void requestFailed (int oid, ObjectAccessException cause) {
log.warning("Aiya! Unable to subscribe to changed client object", "cloid", oid,
"cause", cause);
}
});
} | [
"protected",
"void",
"handleClientObjectChanged",
"(",
"int",
"newCloid",
")",
"{",
"// subscribe to the new client object",
"_omgr",
".",
"subscribeToObject",
"(",
"newCloid",
",",
"new",
"Subscriber",
"<",
"ClientObject",
">",
"(",
")",
"{",
"public",
"void",
"obj... | Called when the server has informed us that our previous client object is going the way of
the Dodo because we're changing screen names. We subscribe to the new object and report to
the client once we've got our hands on it. | [
"Called",
"when",
"the",
"server",
"has",
"informed",
"us",
"that",
"our",
"previous",
"client",
"object",
"is",
"going",
"the",
"way",
"of",
"the",
"Dodo",
"because",
"we",
"re",
"changing",
"screen",
"names",
".",
"We",
"subscribe",
"to",
"the",
"new",
... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/InvocationDirector.java#L338-L372 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.createPlace | public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException
{
return createPlace(config, null, null);
} | java | public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException
{
return createPlace(config, null, null);
} | [
"public",
"PlaceManager",
"createPlace",
"(",
"PlaceConfig",
"config",
")",
"throws",
"InstantiationException",
",",
"InvocationException",
"{",
"return",
"createPlace",
"(",
"config",
",",
"null",
",",
"null",
")",
";",
"}"
] | Creates and registers a new place manager with no delegates.
@see #createPlace(PlaceConfig,List) | [
"Creates",
"and",
"registers",
"a",
"new",
"place",
"manager",
"with",
"no",
"delegates",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L82-L86 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.createPlace | public PlaceManager createPlace (PlaceConfig config, List<PlaceManagerDelegate> delegates)
throws InstantiationException, InvocationException
{
return createPlace(config, delegates, null);
} | java | public PlaceManager createPlace (PlaceConfig config, List<PlaceManagerDelegate> delegates)
throws InstantiationException, InvocationException
{
return createPlace(config, delegates, null);
} | [
"public",
"PlaceManager",
"createPlace",
"(",
"PlaceConfig",
"config",
",",
"List",
"<",
"PlaceManagerDelegate",
">",
"delegates",
")",
"throws",
"InstantiationException",
",",
"InvocationException",
"{",
"return",
"createPlace",
"(",
"config",
",",
"delegates",
",",
... | Creates and registers a new place manager along with the place object to be managed. The
registry takes care of tracking the creation of the object and informing the manager when it
is created.
@param config the configuration object for the place to be created. The {@link PlaceManager}
derived class that should be instantiated to manage the place will be determined from the
config object.
@param delegates a list of {@link PlaceManagerDelegate} instances to be registered with the
manager prior to it being initialized and started up. <em>Note:</em> these delegates will
have dependencies injected into them prior to registering them with the manager.
@return a reference to the place manager, which will have been configured with its place
object and started up (via a call to {@link PlaceManager#startup}.
@exception InstantiationException thrown if an error occurs trying to instantiate and
initialize the place manager.
@exception InvocationException thrown if the place manager returns failure from the call to
{@link PlaceManager#checkPermissions}. The error string returned by that call will be
provided as in the exception. | [
"Creates",
"and",
"registers",
"a",
"new",
"place",
"manager",
"along",
"with",
"the",
"place",
"object",
"to",
"be",
"managed",
".",
"The",
"registry",
"takes",
"care",
"of",
"tracking",
"the",
"creation",
"of",
"the",
"object",
"and",
"informing",
"the",
... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L109-L113 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.enumeratePlaces | public Iterator<PlaceObject> enumeratePlaces ()
{
final Iterator<PlaceManager> itr = _pmgrs.values().iterator();
return new Iterator<PlaceObject>() {
public boolean hasNext () {
return itr.hasNext();
}
public PlaceObject next () {
PlaceManager plmgr = itr.next();
return (plmgr == null) ? null : plmgr.getPlaceObject();
}
public void remove () {
throw new UnsupportedOperationException();
}
};
} | java | public Iterator<PlaceObject> enumeratePlaces ()
{
final Iterator<PlaceManager> itr = _pmgrs.values().iterator();
return new Iterator<PlaceObject>() {
public boolean hasNext () {
return itr.hasNext();
}
public PlaceObject next () {
PlaceManager plmgr = itr.next();
return (plmgr == null) ? null : plmgr.getPlaceObject();
}
public void remove () {
throw new UnsupportedOperationException();
}
};
} | [
"public",
"Iterator",
"<",
"PlaceObject",
">",
"enumeratePlaces",
"(",
")",
"{",
"final",
"Iterator",
"<",
"PlaceManager",
">",
"itr",
"=",
"_pmgrs",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"return",
"new",
"Iterator",
"<",
"PlaceObject",
... | Returns an enumeration of all of the registered place objects. This should only be accessed
on the dobjmgr thread and shouldn't be kept around across event dispatches. | [
"Returns",
"an",
"enumeration",
"of",
"all",
"of",
"the",
"registered",
"place",
"objects",
".",
"This",
"should",
"only",
"be",
"accessed",
"on",
"the",
"dobjmgr",
"thread",
"and",
"shouldn",
"t",
"be",
"kept",
"around",
"across",
"event",
"dispatches",
"."... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L132-L147 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.createPlace | protected PlaceManager createPlace (PlaceConfig config, List<PlaceManagerDelegate> delegates,
PreStartupHook hook)
throws InstantiationException, InvocationException
{
PlaceManager pmgr = null;
try {
// create a place manager using the class supplied in the place config
pmgr = createPlaceManager(config);
// if we have delegates, inject their dependencies and add them
if (delegates != null) {
for (PlaceManagerDelegate delegate : delegates) {
_injector.injectMembers(delegate);
pmgr.addDelegate(delegate);
}
}
// let the pmgr know about us and its configuration
pmgr.init(this, _invmgr, _omgr, selectLocator(config), config);
} catch (Exception e) {
log.warning(e);
throw new InstantiationException("Error creating PlaceManager for " + config);
}
// let the manager abort the whole process if it fails any permissions checks
String errmsg = pmgr.checkPermissions();
if (errmsg != null) {
// give the place manager a chance to clean up after its early initialization process
pmgr.permissionsFailed();
throw new InvocationException(errmsg);
}
// and create and register the place object
PlaceObject plobj = pmgr.createPlaceObject();
_omgr.registerObject(plobj);
// stick the manager into our table
_pmgrs.put(plobj.getOid(), pmgr);
// start the place manager up with the newly created place object
try {
if (hook != null) {
hook.invoke(pmgr);
}
pmgr.startup(plobj);
} catch (Exception e) {
log.warning("Error starting place manager", "obj", plobj, "pmgr", pmgr, e);
}
return pmgr;
} | java | protected PlaceManager createPlace (PlaceConfig config, List<PlaceManagerDelegate> delegates,
PreStartupHook hook)
throws InstantiationException, InvocationException
{
PlaceManager pmgr = null;
try {
// create a place manager using the class supplied in the place config
pmgr = createPlaceManager(config);
// if we have delegates, inject their dependencies and add them
if (delegates != null) {
for (PlaceManagerDelegate delegate : delegates) {
_injector.injectMembers(delegate);
pmgr.addDelegate(delegate);
}
}
// let the pmgr know about us and its configuration
pmgr.init(this, _invmgr, _omgr, selectLocator(config), config);
} catch (Exception e) {
log.warning(e);
throw new InstantiationException("Error creating PlaceManager for " + config);
}
// let the manager abort the whole process if it fails any permissions checks
String errmsg = pmgr.checkPermissions();
if (errmsg != null) {
// give the place manager a chance to clean up after its early initialization process
pmgr.permissionsFailed();
throw new InvocationException(errmsg);
}
// and create and register the place object
PlaceObject plobj = pmgr.createPlaceObject();
_omgr.registerObject(plobj);
// stick the manager into our table
_pmgrs.put(plobj.getOid(), pmgr);
// start the place manager up with the newly created place object
try {
if (hook != null) {
hook.invoke(pmgr);
}
pmgr.startup(plobj);
} catch (Exception e) {
log.warning("Error starting place manager", "obj", plobj, "pmgr", pmgr, e);
}
return pmgr;
} | [
"protected",
"PlaceManager",
"createPlace",
"(",
"PlaceConfig",
"config",
",",
"List",
"<",
"PlaceManagerDelegate",
">",
"delegates",
",",
"PreStartupHook",
"hook",
")",
"throws",
"InstantiationException",
",",
"InvocationException",
"{",
"PlaceManager",
"pmgr",
"=",
... | Creates a place manager using the supplied config, injects dependencies into and registers
the supplied list of delegates, runs the supplied pre-startup hook and finally returns it. | [
"Creates",
"a",
"place",
"manager",
"using",
"the",
"supplied",
"config",
"injects",
"dependencies",
"into",
"and",
"registers",
"the",
"supplied",
"list",
"of",
"delegates",
"runs",
"the",
"supplied",
"pre",
"-",
"startup",
"hook",
"and",
"finally",
"returns",
... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L176-L229 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.unmapPlaceManager | protected void unmapPlaceManager (PlaceManager pmgr)
{
int ploid = pmgr.getPlaceObject().getOid();
// remove it from the table
if (_pmgrs.remove(ploid) == null) {
log.warning("Requested to unmap unmapped place manager", "pmgr", pmgr);
// } else {
// Log.info("Unmapped place manager [class=" + pmgr.getClass().getName() +
// ", ploid=" + ploid + "].");
}
} | java | protected void unmapPlaceManager (PlaceManager pmgr)
{
int ploid = pmgr.getPlaceObject().getOid();
// remove it from the table
if (_pmgrs.remove(ploid) == null) {
log.warning("Requested to unmap unmapped place manager", "pmgr", pmgr);
// } else {
// Log.info("Unmapped place manager [class=" + pmgr.getClass().getName() +
// ", ploid=" + ploid + "].");
}
} | [
"protected",
"void",
"unmapPlaceManager",
"(",
"PlaceManager",
"pmgr",
")",
"{",
"int",
"ploid",
"=",
"pmgr",
".",
"getPlaceObject",
"(",
")",
".",
"getOid",
"(",
")",
";",
"// remove it from the table",
"if",
"(",
"_pmgrs",
".",
"remove",
"(",
"ploid",
")",... | Called by the place manager when it has been shut down. | [
"Called",
"by",
"the",
"place",
"manager",
"when",
"it",
"has",
"been",
"shut",
"down",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L256-L267 | train |
threerings/narya | core/src/main/java/com/threerings/io/Streamer.java | Streamer.isStreamable | public synchronized static boolean isStreamable (Class<?> target)
{
// if we have not yet initialized ourselves, do so now
maybeInit();
// if we already have a streamer, or it's an enum, it's good
if (_streamers.containsKey(target) || target.isEnum()) {
return true;
}
// arrays are streamable, let's check the component type
if (target.isArray()) {
return isStreamable(target.getComponentType());
}
// otherwise it must be Streamable, or an Iterable or Map
return Streamable.class.isAssignableFrom(target) ||
Iterable.class.isAssignableFrom(target) ||
Map.class.isAssignableFrom(target);
} | java | public synchronized static boolean isStreamable (Class<?> target)
{
// if we have not yet initialized ourselves, do so now
maybeInit();
// if we already have a streamer, or it's an enum, it's good
if (_streamers.containsKey(target) || target.isEnum()) {
return true;
}
// arrays are streamable, let's check the component type
if (target.isArray()) {
return isStreamable(target.getComponentType());
}
// otherwise it must be Streamable, or an Iterable or Map
return Streamable.class.isAssignableFrom(target) ||
Iterable.class.isAssignableFrom(target) ||
Map.class.isAssignableFrom(target);
} | [
"public",
"synchronized",
"static",
"boolean",
"isStreamable",
"(",
"Class",
"<",
"?",
">",
"target",
")",
"{",
"// if we have not yet initialized ourselves, do so now",
"maybeInit",
"(",
")",
";",
"// if we already have a streamer, or it's an enum, it's good",
"if",
"(",
"... | Returns true if the supplied target class can be streamed using a streamer. | [
"Returns",
"true",
"if",
"the",
"supplied",
"target",
"class",
"can",
"be",
"streamed",
"using",
"a",
"streamer",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/Streamer.java#L69-L88 | train |
threerings/narya | core/src/main/java/com/threerings/io/Streamer.java | Streamer.getStreamerClass | public static Class<?> getStreamerClass (Object object)
{
return (object instanceof Enum<?>) ?
((Enum<?>)object).getDeclaringClass() : object.getClass();
} | java | public static Class<?> getStreamerClass (Object object)
{
return (object instanceof Enum<?>) ?
((Enum<?>)object).getDeclaringClass() : object.getClass();
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"getStreamerClass",
"(",
"Object",
"object",
")",
"{",
"return",
"(",
"object",
"instanceof",
"Enum",
"<",
"?",
">",
")",
"?",
"(",
"(",
"Enum",
"<",
"?",
">",
")",
"object",
")",
".",
"getDeclaringClass",
... | Returns the class that should be used when streaming this object. In general that is the
object's natural class, but for enum values, that might be its declaring class as enums use
classes in a way that would otherwise pollute our id to class mapping space. | [
"Returns",
"the",
"class",
"that",
"should",
"be",
"used",
"when",
"streaming",
"this",
"object",
".",
"In",
"general",
"that",
"is",
"the",
"object",
"s",
"natural",
"class",
"but",
"for",
"enum",
"values",
"that",
"might",
"be",
"its",
"declaring",
"clas... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/Streamer.java#L95-L99 | train |
threerings/narya | core/src/main/java/com/threerings/io/Streamer.java | Streamer.getCollectionClass | public static Class<?> getCollectionClass (Class<?> clazz)
{
if (Streamable.class.isAssignableFrom(clazz)) {
// the class is natively streamable, let's ignore it
return null;
}
for (Class<?> collClass : BasicStreamers.CollectionStreamer.SPECIFICITY_ORDER) {
if (collClass.isAssignableFrom(clazz)) {
return collClass;
}
}
return null;
} | java | public static Class<?> getCollectionClass (Class<?> clazz)
{
if (Streamable.class.isAssignableFrom(clazz)) {
// the class is natively streamable, let's ignore it
return null;
}
for (Class<?> collClass : BasicStreamers.CollectionStreamer.SPECIFICITY_ORDER) {
if (collClass.isAssignableFrom(clazz)) {
return collClass;
}
}
return null;
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"getCollectionClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"Streamable",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"// the class is natively streamable, let's ignore it",... | If the specified class is not Streamable and is a Collection type, return the
most specific supported Collection interface type; otherwise return null. | [
"If",
"the",
"specified",
"class",
"is",
"not",
"Streamable",
"and",
"is",
"a",
"Collection",
"type",
"return",
"the",
"most",
"specific",
"supported",
"Collection",
"interface",
"type",
";",
"otherwise",
"return",
"null",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/Streamer.java#L105-L117 | train |
threerings/narya | core/src/main/java/com/threerings/io/Streamer.java | Streamer.create | protected static Streamer create (Class<?> target)
throws IOException
{
// validate that the class is really streamable
boolean isInner = false, isStatic = Modifier.isStatic(target.getModifiers());
try {
isInner = (target.getDeclaringClass() != null);
} catch (Throwable t) {
log.warning("Failure checking innerness of class",
"class", target.getName(), "error", t);
}
if (isInner && !isStatic) {
throw new IllegalArgumentException(
"Cannot stream non-static inner class: " + target.getName());
}
// create streamers for array types
if (target.isArray()) {
Class<?> componentType = target.getComponentType();
if (Modifier.isFinal(componentType.getModifiers())) {
Streamer delegate = Streamer.getStreamer(componentType);
if (delegate != null) {
return new FinalArrayStreamer(componentType, delegate);
} // else: error, below
} else if (isStreamable(componentType)) {
return new ArrayStreamer(componentType);
}
String errmsg = "Aiya! Streamer created for array type but we have no registered " +
"streamer for the element type [type=" + target.getName() + "]";
throw new RuntimeException(errmsg);
}
// create streamers for enum types
if (target.isEnum()) {
switch (ENUM_POLICY) {
case NAME_WITH_BYTE_ENUM:
case ORDINAL_WITH_BYTE_ENUM:
if (ByteEnum.class.isAssignableFrom(target)) {
return new ByteEnumStreamer(target);
}
break;
default:
// we do not care if it is a ByteEnum, we move on...
break;
}
switch (ENUM_POLICY) {
case NAME_WITH_BYTE_ENUM:
case NAME:
return new NameEnumStreamer(target);
default:
List<?> universe = ImmutableList.copyOf(target.getEnumConstants());
int maxOrdinal = universe.size() - 1;
if (maxOrdinal <= Byte.MAX_VALUE) {
return new ByteOrdEnumStreamer(target, universe);
} else if (maxOrdinal <= Short.MAX_VALUE) {
return new ShortOrdEnumStreamer(target, universe);
} else {
return new IntOrdEnumStreamer(target, universe);
}
}
}
// create Streamers for other types
Method reader = null;
Method writer = null;
try {
reader = target.getMethod(READER_METHOD_NAME, READER_ARGS);
} catch (NoSuchMethodException nsme) {
// nothing to worry about, we just don't have one
}
try {
writer = target.getMethod(WRITER_METHOD_NAME, WRITER_ARGS);
} catch (NoSuchMethodException nsme) {
// nothing to worry about, we just don't have one
}
// if there is no reader and no writer, we can do a simpler thing
if ((reader == null) && (writer == null)) {
return new ClassStreamer(target);
} else {
return new CustomClassStreamer(target, reader, writer);
}
} | java | protected static Streamer create (Class<?> target)
throws IOException
{
// validate that the class is really streamable
boolean isInner = false, isStatic = Modifier.isStatic(target.getModifiers());
try {
isInner = (target.getDeclaringClass() != null);
} catch (Throwable t) {
log.warning("Failure checking innerness of class",
"class", target.getName(), "error", t);
}
if (isInner && !isStatic) {
throw new IllegalArgumentException(
"Cannot stream non-static inner class: " + target.getName());
}
// create streamers for array types
if (target.isArray()) {
Class<?> componentType = target.getComponentType();
if (Modifier.isFinal(componentType.getModifiers())) {
Streamer delegate = Streamer.getStreamer(componentType);
if (delegate != null) {
return new FinalArrayStreamer(componentType, delegate);
} // else: error, below
} else if (isStreamable(componentType)) {
return new ArrayStreamer(componentType);
}
String errmsg = "Aiya! Streamer created for array type but we have no registered " +
"streamer for the element type [type=" + target.getName() + "]";
throw new RuntimeException(errmsg);
}
// create streamers for enum types
if (target.isEnum()) {
switch (ENUM_POLICY) {
case NAME_WITH_BYTE_ENUM:
case ORDINAL_WITH_BYTE_ENUM:
if (ByteEnum.class.isAssignableFrom(target)) {
return new ByteEnumStreamer(target);
}
break;
default:
// we do not care if it is a ByteEnum, we move on...
break;
}
switch (ENUM_POLICY) {
case NAME_WITH_BYTE_ENUM:
case NAME:
return new NameEnumStreamer(target);
default:
List<?> universe = ImmutableList.copyOf(target.getEnumConstants());
int maxOrdinal = universe.size() - 1;
if (maxOrdinal <= Byte.MAX_VALUE) {
return new ByteOrdEnumStreamer(target, universe);
} else if (maxOrdinal <= Short.MAX_VALUE) {
return new ShortOrdEnumStreamer(target, universe);
} else {
return new IntOrdEnumStreamer(target, universe);
}
}
}
// create Streamers for other types
Method reader = null;
Method writer = null;
try {
reader = target.getMethod(READER_METHOD_NAME, READER_ARGS);
} catch (NoSuchMethodException nsme) {
// nothing to worry about, we just don't have one
}
try {
writer = target.getMethod(WRITER_METHOD_NAME, WRITER_ARGS);
} catch (NoSuchMethodException nsme) {
// nothing to worry about, we just don't have one
}
// if there is no reader and no writer, we can do a simpler thing
if ((reader == null) && (writer == null)) {
return new ClassStreamer(target);
} else {
return new CustomClassStreamer(target, reader, writer);
}
} | [
"protected",
"static",
"Streamer",
"create",
"(",
"Class",
"<",
"?",
">",
"target",
")",
"throws",
"IOException",
"{",
"// validate that the class is really streamable",
"boolean",
"isInner",
"=",
"false",
",",
"isStatic",
"=",
"Modifier",
".",
"isStatic",
"(",
"t... | Create the appropriate Streamer for a newly-seen class. | [
"Create",
"the",
"appropriate",
"Streamer",
"for",
"a",
"newly",
"-",
"seen",
"class",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/Streamer.java#L229-L317 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.applyToOccupants | public void applyToOccupants (OccupantOp op)
{
if (_plobj != null) {
for (OccupantInfo info : _plobj.occupantInfo) {
op.apply(info);
}
}
} | java | public void applyToOccupants (OccupantOp op)
{
if (_plobj != null) {
for (OccupantInfo info : _plobj.occupantInfo) {
op.apply(info);
}
}
} | [
"public",
"void",
"applyToOccupants",
"(",
"OccupantOp",
"op",
")",
"{",
"if",
"(",
"_plobj",
"!=",
"null",
")",
"{",
"for",
"(",
"OccupantInfo",
"info",
":",
"_plobj",
".",
"occupantInfo",
")",
"{",
"op",
".",
"apply",
"(",
"info",
")",
";",
"}",
"}... | Applies the supplied occupant operation to each occupant currently present in this place. | [
"Applies",
"the",
"supplied",
"occupant",
"operation",
"to",
"each",
"occupant",
"currently",
"present",
"in",
"this",
"place",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L152-L159 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.init | public void init (PlaceRegistry registry, InvocationManager invmgr, RootDObjectManager omgr,
BodyLocator locator, PlaceConfig config)
{
_registry = registry;
_invmgr = invmgr;
_omgr = omgr;
_locator = locator;
_config = config;
// initialize our delegates
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.init(PlaceManager.this, _omgr, _invmgr);
}
});
// let derived classes do initialization stuff
try {
didInit();
} catch (Throwable t) {
log.warning("Manager choked in didInit()", "where", where(), t);
}
} | java | public void init (PlaceRegistry registry, InvocationManager invmgr, RootDObjectManager omgr,
BodyLocator locator, PlaceConfig config)
{
_registry = registry;
_invmgr = invmgr;
_omgr = omgr;
_locator = locator;
_config = config;
// initialize our delegates
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.init(PlaceManager.this, _omgr, _invmgr);
}
});
// let derived classes do initialization stuff
try {
didInit();
} catch (Throwable t) {
log.warning("Manager choked in didInit()", "where", where(), t);
}
} | [
"public",
"void",
"init",
"(",
"PlaceRegistry",
"registry",
",",
"InvocationManager",
"invmgr",
",",
"RootDObjectManager",
"omgr",
",",
"BodyLocator",
"locator",
",",
"PlaceConfig",
"config",
")",
"{",
"_registry",
"=",
"registry",
";",
"_invmgr",
"=",
"invmgr",
... | Called by the place registry after creating this place manager. | [
"Called",
"by",
"the",
"place",
"registry",
"after",
"creating",
"this",
"place",
"manager",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L188-L211 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.addDelegate | public void addDelegate (PlaceManagerDelegate delegate)
{
if (_delegates == null) {
_delegates = Lists.newArrayList();
}
if (_omgr != null) {
delegate.init(this, _omgr, _invmgr);
delegate.didInit(_config);
}
_delegates.add(delegate);
} | java | public void addDelegate (PlaceManagerDelegate delegate)
{
if (_delegates == null) {
_delegates = Lists.newArrayList();
}
if (_omgr != null) {
delegate.init(this, _omgr, _invmgr);
delegate.didInit(_config);
}
_delegates.add(delegate);
} | [
"public",
"void",
"addDelegate",
"(",
"PlaceManagerDelegate",
"delegate",
")",
"{",
"if",
"(",
"_delegates",
"==",
"null",
")",
"{",
"_delegates",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"}",
"if",
"(",
"_omgr",
"!=",
"null",
")",
"{",
"delegat... | Adds the supplied delegate to the list for this manager. | [
"Adds",
"the",
"supplied",
"delegate",
"to",
"the",
"list",
"for",
"this",
"manager",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L216-L226 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.applyToDelegates | public void applyToDelegates (DelegateOp op)
{
if (_delegates != null) {
for (int ii = 0, ll = _delegates.size(); ii < ll; ii++) {
PlaceManagerDelegate delegate = _delegates.get(ii);
if (op.shouldApply(delegate)) {
op.apply(delegate);
}
}
}
} | java | public void applyToDelegates (DelegateOp op)
{
if (_delegates != null) {
for (int ii = 0, ll = _delegates.size(); ii < ll; ii++) {
PlaceManagerDelegate delegate = _delegates.get(ii);
if (op.shouldApply(delegate)) {
op.apply(delegate);
}
}
}
} | [
"public",
"void",
"applyToDelegates",
"(",
"DelegateOp",
"op",
")",
"{",
"if",
"(",
"_delegates",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"ii",
"=",
"0",
",",
"ll",
"=",
"_delegates",
".",
"size",
"(",
")",
";",
"ii",
"<",
"ll",
";",
"ii",
"++... | Applies the supplied operation to this manager's registered delegates. | [
"Applies",
"the",
"supplied",
"operation",
"to",
"this",
"manager",
"s",
"registered",
"delegates",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L231-L241 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.startup | public void startup (PlaceObject plobj)
{
// keep track of this
_plobj = plobj;
// we usually want to create and register a speaker service instance that clients can use
// to speak in this place
if (shouldCreateSpeakService()) {
plobj.setSpeakService(addProvider(createSpeakHandler(plobj), SpeakMarshaller.class));
}
// we'll need to hear about place object events
plobj.addListener(this);
plobj.addListener(_bodyUpdater);
plobj.addListener(_occListener);
plobj.addListener(_deathListener);
// configure this place's access controller
plobj.setAccessController(getAccessController());
// let our derived classes do their thang
try {
didStartup();
} catch (Throwable t) {
log.warning("Manager choked in didStartup()", "where", where(), t);
}
// since we start empty, we need to immediately assume shutdown
checkShutdownInterval();
} | java | public void startup (PlaceObject plobj)
{
// keep track of this
_plobj = plobj;
// we usually want to create and register a speaker service instance that clients can use
// to speak in this place
if (shouldCreateSpeakService()) {
plobj.setSpeakService(addProvider(createSpeakHandler(plobj), SpeakMarshaller.class));
}
// we'll need to hear about place object events
plobj.addListener(this);
plobj.addListener(_bodyUpdater);
plobj.addListener(_occListener);
plobj.addListener(_deathListener);
// configure this place's access controller
plobj.setAccessController(getAccessController());
// let our derived classes do their thang
try {
didStartup();
} catch (Throwable t) {
log.warning("Manager choked in didStartup()", "where", where(), t);
}
// since we start empty, we need to immediately assume shutdown
checkShutdownInterval();
} | [
"public",
"void",
"startup",
"(",
"PlaceObject",
"plobj",
")",
"{",
"// keep track of this",
"_plobj",
"=",
"plobj",
";",
"// we usually want to create and register a speaker service instance that clients can use",
"// to speak in this place",
"if",
"(",
"shouldCreateSpeakService",... | Called by the place manager after the place object has been successfully created. | [
"Called",
"by",
"the",
"place",
"manager",
"after",
"the",
"place",
"object",
"has",
"been",
"successfully",
"created",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L260-L289 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.registerMessageHandler | @Deprecated
public void registerMessageHandler (String name, MessageHandler handler)
{
// create our handler map if necessary
if (_msghandlers == null) {
_msghandlers = Maps.newHashMap();
}
_msghandlers.put(name, handler);
} | java | @Deprecated
public void registerMessageHandler (String name, MessageHandler handler)
{
// create our handler map if necessary
if (_msghandlers == null) {
_msghandlers = Maps.newHashMap();
}
_msghandlers.put(name, handler);
} | [
"@",
"Deprecated",
"public",
"void",
"registerMessageHandler",
"(",
"String",
"name",
",",
"MessageHandler",
"handler",
")",
"{",
"// create our handler map if necessary",
"if",
"(",
"_msghandlers",
"==",
"null",
")",
"{",
"_msghandlers",
"=",
"Maps",
".",
"newHashM... | Registers a particular message handler instance to be used when processing message events
with the specified name.
@param name the message name of the message events that should be handled by this handler.
@param handler the handler to be registered.
@deprecated Use dynamically bound methods instead. See {@link DynamicListener}. | [
"Registers",
"a",
"particular",
"message",
"handler",
"instance",
"to",
"be",
"used",
"when",
"processing",
"message",
"events",
"with",
"the",
"specified",
"name",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L361-L369 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.messageReceived | public void messageReceived (MessageEvent event)
{
if (_msghandlers != null) {
MessageHandler handler = _msghandlers.get(event.getName());
if (handler != null) {
handler.handleEvent(event, this);
}
}
// If the message is directed at us, see if it's a request for a method invocation
if (event.isPrivate()) { // aka if (event instanceof ServerMessageEvent)
// the first argument should be the client object of the caller or null if it is
// a server-originated event
int srcoid = event.getSourceOid();
DObject source = (srcoid <= 0) ? null : _omgr.getObject(srcoid);
String method = event.getName();
Object[] args = event.getArgs(), nargs;
// validate that this call is allowed
if (!allowManagerCall(method)) {
log.warning("Client tried to invoke forbidden manager call!",
"source", source, "method", method, "args", args);
return;
}
if (args == null) {
nargs = new Object[] { source };
} else {
nargs = new Object[args.length+1];
nargs[0] = source;
System.arraycopy(args, 0, nargs, 1, args.length);
}
// Lazily create our dispatcher now that it's actually getting a message
if (_dispatcher == null) {
Class<?> clazz = getClass();
MethodFinder finder = _dispatcherFinders.get(clazz);
if (finder == null) {
finder = new MethodFinder(clazz);
_dispatcherFinders.put(clazz, finder);
}
_dispatcher = new DynamicListener<DSet.Entry>(this, finder);
}
_dispatcher.dispatchMethod(method, nargs);
}
} | java | public void messageReceived (MessageEvent event)
{
if (_msghandlers != null) {
MessageHandler handler = _msghandlers.get(event.getName());
if (handler != null) {
handler.handleEvent(event, this);
}
}
// If the message is directed at us, see if it's a request for a method invocation
if (event.isPrivate()) { // aka if (event instanceof ServerMessageEvent)
// the first argument should be the client object of the caller or null if it is
// a server-originated event
int srcoid = event.getSourceOid();
DObject source = (srcoid <= 0) ? null : _omgr.getObject(srcoid);
String method = event.getName();
Object[] args = event.getArgs(), nargs;
// validate that this call is allowed
if (!allowManagerCall(method)) {
log.warning("Client tried to invoke forbidden manager call!",
"source", source, "method", method, "args", args);
return;
}
if (args == null) {
nargs = new Object[] { source };
} else {
nargs = new Object[args.length+1];
nargs[0] = source;
System.arraycopy(args, 0, nargs, 1, args.length);
}
// Lazily create our dispatcher now that it's actually getting a message
if (_dispatcher == null) {
Class<?> clazz = getClass();
MethodFinder finder = _dispatcherFinders.get(clazz);
if (finder == null) {
finder = new MethodFinder(clazz);
_dispatcherFinders.put(clazz, finder);
}
_dispatcher = new DynamicListener<DSet.Entry>(this, finder);
}
_dispatcher.dispatchMethod(method, nargs);
}
} | [
"public",
"void",
"messageReceived",
"(",
"MessageEvent",
"event",
")",
"{",
"if",
"(",
"_msghandlers",
"!=",
"null",
")",
"{",
"MessageHandler",
"handler",
"=",
"_msghandlers",
".",
"get",
"(",
"event",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"ha... | from interface MessageListener | [
"from",
"interface",
"MessageListener"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L372-L417 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.addProvider | protected <T extends InvocationMarshaller<?>> T addProvider (
InvocationProvider prov, Class<T> mclass)
{
T marsh = _invmgr.registerProvider(prov, mclass);
_marshallers.add(marsh);
return marsh;
} | java | protected <T extends InvocationMarshaller<?>> T addProvider (
InvocationProvider prov, Class<T> mclass)
{
T marsh = _invmgr.registerProvider(prov, mclass);
_marshallers.add(marsh);
return marsh;
} | [
"protected",
"<",
"T",
"extends",
"InvocationMarshaller",
"<",
"?",
">",
">",
"T",
"addProvider",
"(",
"InvocationProvider",
"prov",
",",
"Class",
"<",
"T",
">",
"mclass",
")",
"{",
"T",
"marsh",
"=",
"_invmgr",
".",
"registerProvider",
"(",
"prov",
",",
... | Registers an invocation provider and notes the registration such that it will be
automatically cleared when this manager shuts down. | [
"Registers",
"an",
"invocation",
"provider",
"and",
"notes",
"the",
"registration",
"such",
"that",
"it",
"will",
"be",
"automatically",
"cleared",
"when",
"this",
"manager",
"shuts",
"down",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L588-L594 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.addDispatcher | protected <T extends InvocationMarshaller<?>> T addDispatcher (InvocationDispatcher<T> disp)
{
T marsh = _invmgr.registerDispatcher(disp);
_marshallers.add(marsh);
return marsh;
} | java | protected <T extends InvocationMarshaller<?>> T addDispatcher (InvocationDispatcher<T> disp)
{
T marsh = _invmgr.registerDispatcher(disp);
_marshallers.add(marsh);
return marsh;
} | [
"protected",
"<",
"T",
"extends",
"InvocationMarshaller",
"<",
"?",
">",
">",
"T",
"addDispatcher",
"(",
"InvocationDispatcher",
"<",
"T",
">",
"disp",
")",
"{",
"T",
"marsh",
"=",
"_invmgr",
".",
"registerDispatcher",
"(",
"disp",
")",
";",
"_marshallers",
... | Registers an invocation dispatcher and notes the registration such that it will be
automatically cleared when this manager shuts down. | [
"Registers",
"an",
"invocation",
"dispatcher",
"and",
"notes",
"the",
"registration",
"such",
"that",
"it",
"will",
"be",
"automatically",
"cleared",
"when",
"this",
"manager",
"shuts",
"down",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L600-L605 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.bodyEntered | protected void bodyEntered (final int bodyOid)
{
log.debug("Body entered", "where", where(), "oid", bodyOid);
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.bodyEntered(bodyOid);
}
});
// if we were on the road to shutting down, step off
cancelShutdowner();
} | java | protected void bodyEntered (final int bodyOid)
{
log.debug("Body entered", "where", where(), "oid", bodyOid);
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.bodyEntered(bodyOid);
}
});
// if we were on the road to shutting down, step off
cancelShutdowner();
} | [
"protected",
"void",
"bodyEntered",
"(",
"final",
"int",
"bodyOid",
")",
"{",
"log",
".",
"debug",
"(",
"\"Body entered\"",
",",
"\"where\"",
",",
"where",
"(",
")",
",",
"\"oid\"",
",",
"bodyOid",
")",
";",
"// let our delegates know what's up",
"applyToDelegat... | Called when a body object enters this place. | [
"Called",
"when",
"a",
"body",
"object",
"enters",
"this",
"place",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L610-L624 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.bodyLeft | protected void bodyLeft (final int bodyOid)
{
log.debug("Body left", "where", where(), "oid", bodyOid);
// if their occupant info hasn't been removed (which may be the case if they logged off
// rather than left via a MoveTo request), we need to get it on out of here
Integer key = Integer.valueOf(bodyOid);
if (_plobj.occupantInfo.containsKey(key)) {
_plobj.removeFromOccupantInfo(key);
}
// clear out their canonical (local) occupant info record
OccupantInfo leaver = _occInfo.remove(bodyOid);
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override public void apply (PlaceManagerDelegate delegate) {
delegate.bodyLeft(bodyOid);
}
});
// if that leaves us with zero occupants, maybe do something
if (shouldDeclareEmpty(leaver)) {
placeBecameEmpty();
}
} | java | protected void bodyLeft (final int bodyOid)
{
log.debug("Body left", "where", where(), "oid", bodyOid);
// if their occupant info hasn't been removed (which may be the case if they logged off
// rather than left via a MoveTo request), we need to get it on out of here
Integer key = Integer.valueOf(bodyOid);
if (_plobj.occupantInfo.containsKey(key)) {
_plobj.removeFromOccupantInfo(key);
}
// clear out their canonical (local) occupant info record
OccupantInfo leaver = _occInfo.remove(bodyOid);
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override public void apply (PlaceManagerDelegate delegate) {
delegate.bodyLeft(bodyOid);
}
});
// if that leaves us with zero occupants, maybe do something
if (shouldDeclareEmpty(leaver)) {
placeBecameEmpty();
}
} | [
"protected",
"void",
"bodyLeft",
"(",
"final",
"int",
"bodyOid",
")",
"{",
"log",
".",
"debug",
"(",
"\"Body left\"",
",",
"\"where\"",
",",
"where",
"(",
")",
",",
"\"oid\"",
",",
"bodyOid",
")",
";",
"// if their occupant info hasn't been removed (which may be t... | Called when a body object leaves this place. | [
"Called",
"when",
"a",
"body",
"object",
"leaves",
"this",
"place",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L629-L654 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.bodyUpdated | protected void bodyUpdated (final OccupantInfo info)
{
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.bodyUpdated(info);
}
});
} | java | protected void bodyUpdated (final OccupantInfo info)
{
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.bodyUpdated(info);
}
});
} | [
"protected",
"void",
"bodyUpdated",
"(",
"final",
"OccupantInfo",
"info",
")",
"{",
"// let our delegates know what's up",
"applyToDelegates",
"(",
"new",
"DelegateOp",
"(",
"PlaceManagerDelegate",
".",
"class",
")",
"{",
"@",
"Override",
"public",
"void",
"apply",
... | Called when a body's occupant info is updated. | [
"Called",
"when",
"a",
"body",
"s",
"occupant",
"info",
"is",
"updated",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L682-L691 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.placeBecameEmpty | protected void placeBecameEmpty ()
{
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.placeBecameEmpty();
}
});
// Log.info("Place became empty " + where() + ".");
checkShutdownInterval();
} | java | protected void placeBecameEmpty ()
{
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.placeBecameEmpty();
}
});
// Log.info("Place became empty " + where() + ".");
checkShutdownInterval();
} | [
"protected",
"void",
"placeBecameEmpty",
"(",
")",
"{",
"// let our delegates know what's up",
"applyToDelegates",
"(",
"new",
"DelegateOp",
"(",
"PlaceManagerDelegate",
".",
"class",
")",
"{",
"@",
"Override",
"public",
"void",
"apply",
"(",
"PlaceManagerDelegate",
"... | Called when we transition from having bodies in the place to not having any bodies in the
place. Some places may take this as a sign to pack it in, others may wish to stick
around. In any case, they can override this method to do their thing. | [
"Called",
"when",
"we",
"transition",
"from",
"having",
"bodies",
"in",
"the",
"place",
"to",
"not",
"having",
"any",
"bodies",
"in",
"the",
"place",
".",
"Some",
"places",
"may",
"take",
"this",
"as",
"a",
"sign",
"to",
"pack",
"it",
"in",
"others",
"... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L698-L711 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceManager.java | PlaceManager.checkShutdownInterval | protected void checkShutdownInterval ()
{
// queue up a shutdown interval, unless we've already got one.
long idlePeriod = idleUnloadPeriod();
if (idlePeriod > 0L && _shutdownInterval == null) {
(_shutdownInterval = _omgr.newInterval(new Runnable() {
public void run () {
log.debug("Unloading idle place '" + where() + "'.");
shutdown();
}
})).schedule(idlePeriod);
}
} | java | protected void checkShutdownInterval ()
{
// queue up a shutdown interval, unless we've already got one.
long idlePeriod = idleUnloadPeriod();
if (idlePeriod > 0L && _shutdownInterval == null) {
(_shutdownInterval = _omgr.newInterval(new Runnable() {
public void run () {
log.debug("Unloading idle place '" + where() + "'.");
shutdown();
}
})).schedule(idlePeriod);
}
} | [
"protected",
"void",
"checkShutdownInterval",
"(",
")",
"{",
"// queue up a shutdown interval, unless we've already got one.",
"long",
"idlePeriod",
"=",
"idleUnloadPeriod",
"(",
")",
";",
"if",
"(",
"idlePeriod",
">",
"0L",
"&&",
"_shutdownInterval",
"==",
"null",
")",... | Called on startup and when the place is empty. | [
"Called",
"on",
"startup",
"and",
"when",
"the",
"place",
"is",
"empty",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceManager.java#L716-L728 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java | SpeakUtil.sendInfo | public static void sendInfo (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.INFO);
} | java | public static void sendInfo (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.INFO);
} | [
"public",
"static",
"void",
"sendInfo",
"(",
"DObject",
"speakObj",
",",
"String",
"bundle",
",",
"String",
"message",
")",
"{",
"sendSystem",
"(",
"speakObj",
",",
"bundle",
",",
"message",
",",
"SystemMessage",
".",
"INFO",
")",
";",
"}"
] | Sends a system INFO message notification to the specified object with the supplied message
content. A system message is one that will be rendered where the speak messages are
rendered, but in a way that makes it clear that it is a message from the server.
Info messages are sent when something happens that was neither directly triggered by the
user, nor requires direct action.
@param speakObj the object on which to deliver the message.
@param bundle the name of the localization bundle that should be used to translate this
system message prior to displaying it to the client.
@param message the text of the message. | [
"Sends",
"a",
"system",
"INFO",
"message",
"notification",
"to",
"the",
"specified",
"object",
"with",
"the",
"supplied",
"message",
"content",
".",
"A",
"system",
"message",
"is",
"one",
"that",
"will",
"be",
"rendered",
"where",
"the",
"speak",
"messages",
... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java#L125-L128 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java | SpeakUtil.sendFeedback | public static void sendFeedback (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.FEEDBACK);
} | java | public static void sendFeedback (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.FEEDBACK);
} | [
"public",
"static",
"void",
"sendFeedback",
"(",
"DObject",
"speakObj",
",",
"String",
"bundle",
",",
"String",
"message",
")",
"{",
"sendSystem",
"(",
"speakObj",
",",
"bundle",
",",
"message",
",",
"SystemMessage",
".",
"FEEDBACK",
")",
";",
"}"
] | Sends a system FEEDBACK message notification to the specified object with the supplied
message content. A system message is one that will be rendered where the speak messages are
rendered, but in a way that makes it clear that it is a message from the server.
Feedback messages are sent in direct response to a user action, usually to indicate success
or failure of the user's action.
@param speakObj the object on which to deliver the message.
@param bundle the name of the localization bundle that should be used to translate this
system message prior to displaying it to the client.
@param message the text of the message. | [
"Sends",
"a",
"system",
"FEEDBACK",
"message",
"notification",
"to",
"the",
"specified",
"object",
"with",
"the",
"supplied",
"message",
"content",
".",
"A",
"system",
"message",
"is",
"one",
"that",
"will",
"be",
"rendered",
"where",
"the",
"speak",
"messages... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java#L143-L146 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java | SpeakUtil.sendAttention | public static void sendAttention (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.ATTENTION);
} | java | public static void sendAttention (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.ATTENTION);
} | [
"public",
"static",
"void",
"sendAttention",
"(",
"DObject",
"speakObj",
",",
"String",
"bundle",
",",
"String",
"message",
")",
"{",
"sendSystem",
"(",
"speakObj",
",",
"bundle",
",",
"message",
",",
"SystemMessage",
".",
"ATTENTION",
")",
";",
"}"
] | Sends a system ATTENTION message notification to the specified object with the supplied
message content. A system message is one that will be rendered where the speak messages are
rendered, but in a way that makes it clear that it is a message from the server.
Attention messages are sent when something requires user action that did not result from
direct action by the user.
@param speakObj the object on which to deliver the message.
@param bundle the name of the localization bundle that should be used to translate this
system message prior to displaying it to the client.
@param message the text of the message. | [
"Sends",
"a",
"system",
"ATTENTION",
"message",
"notification",
"to",
"the",
"specified",
"object",
"with",
"the",
"supplied",
"message",
"content",
".",
"A",
"system",
"message",
"is",
"one",
"that",
"will",
"be",
"rendered",
"where",
"the",
"speak",
"message... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java#L161-L164 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java | SpeakUtil.sendMessage | public static void sendMessage (DObject speakObj, ChatMessage msg)
{
if (speakObj == null) {
log.warning("Dropping speak message, no speak obj '" + msg + "'.", new Exception());
return;
}
// post the message to the relevant object
speakObj.postMessage(ChatCodes.CHAT_NOTIFICATION, new Object[] { msg });
// if this is a user message; add it to the heard history of all users that can "hear" it
if (!(msg instanceof UserMessage)) {
return;
} else if (speakObj instanceof SpeakObject) {
_messageMapper.omgr = (RootDObjectManager)speakObj.getManager();
_messageMapper.message = (UserMessage)msg;
((SpeakObject)speakObj).applyToListeners(_messageMapper);
_messageMapper.omgr = null;
_messageMapper.message = null;
} else {
log.info("Unable to note listeners", "dclass", speakObj.getClass(), "msg", msg);
}
} | java | public static void sendMessage (DObject speakObj, ChatMessage msg)
{
if (speakObj == null) {
log.warning("Dropping speak message, no speak obj '" + msg + "'.", new Exception());
return;
}
// post the message to the relevant object
speakObj.postMessage(ChatCodes.CHAT_NOTIFICATION, new Object[] { msg });
// if this is a user message; add it to the heard history of all users that can "hear" it
if (!(msg instanceof UserMessage)) {
return;
} else if (speakObj instanceof SpeakObject) {
_messageMapper.omgr = (RootDObjectManager)speakObj.getManager();
_messageMapper.message = (UserMessage)msg;
((SpeakObject)speakObj).applyToListeners(_messageMapper);
_messageMapper.omgr = null;
_messageMapper.message = null;
} else {
log.info("Unable to note listeners", "dclass", speakObj.getClass(), "msg", msg);
}
} | [
"public",
"static",
"void",
"sendMessage",
"(",
"DObject",
"speakObj",
",",
"ChatMessage",
"msg",
")",
"{",
"if",
"(",
"speakObj",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Dropping speak message, no speak obj '\"",
"+",
"msg",
"+",
"\"'.\"",
",",... | Send the specified message on the specified object. | [
"Send",
"the",
"specified",
"message",
"on",
"the",
"specified",
"object",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java#L169-L193 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java | SpeakUtil.sendSystem | protected static void sendSystem (DObject speakObj, String bundle, String message, byte level)
{
sendMessage(speakObj, new SystemMessage(message, bundle, level));
} | java | protected static void sendSystem (DObject speakObj, String bundle, String message, byte level)
{
sendMessage(speakObj, new SystemMessage(message, bundle, level));
} | [
"protected",
"static",
"void",
"sendSystem",
"(",
"DObject",
"speakObj",
",",
"String",
"bundle",
",",
"String",
"message",
",",
"byte",
"level",
")",
"{",
"sendMessage",
"(",
"speakObj",
",",
"new",
"SystemMessage",
"(",
"message",
",",
"bundle",
",",
"leve... | Send the specified system message on the specified dobj. | [
"Send",
"the",
"specified",
"system",
"message",
"on",
"the",
"specified",
"dobj",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java#L216-L219 | train |
davidmoten/grumpy | grumpy-ogc-layers/src/main/java/com/github/davidmoten/grumpy/wms/layer/darkness/SunUtil.java | SunUtil.getTwilight | public static Twilight getTwilight(double sunDistanceRadians) {
double altDegrees = 90.0 - Math.toDegrees(sunDistanceRadians);
if (altDegrees >= 0.0) {
return Twilight.DAYLIGHT;
} else if (altDegrees >= -6.0) {
return Twilight.CIVIL;
} else if (altDegrees >= -12.0) {
return Twilight.NAUTICAL;
} else if (altDegrees >= -18.0) {
return Twilight.ASTRONOMICAL;
}
return Twilight.NIGHT;
} | java | public static Twilight getTwilight(double sunDistanceRadians) {
double altDegrees = 90.0 - Math.toDegrees(sunDistanceRadians);
if (altDegrees >= 0.0) {
return Twilight.DAYLIGHT;
} else if (altDegrees >= -6.0) {
return Twilight.CIVIL;
} else if (altDegrees >= -12.0) {
return Twilight.NAUTICAL;
} else if (altDegrees >= -18.0) {
return Twilight.ASTRONOMICAL;
}
return Twilight.NIGHT;
} | [
"public",
"static",
"Twilight",
"getTwilight",
"(",
"double",
"sunDistanceRadians",
")",
"{",
"double",
"altDegrees",
"=",
"90.0",
"-",
"Math",
".",
"toDegrees",
"(",
"sunDistanceRadians",
")",
";",
"if",
"(",
"altDegrees",
">=",
"0.0",
")",
"{",
"return",
"... | Return the twilight condition for a point which is a given great circle
distance from the current sub solar point.
@param sunDistanceRadians
- from the current positon to the sub solar point
@return The twilight condition | [
"Return",
"the",
"twilight",
"condition",
"for",
"a",
"point",
"which",
"is",
"a",
"given",
"great",
"circle",
"distance",
"from",
"the",
"current",
"sub",
"solar",
"point",
"."
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-ogc-layers/src/main/java/com/github/davidmoten/grumpy/wms/layer/darkness/SunUtil.java#L42-L56 | train |
davidmoten/grumpy | grumpy-ogc-layers/src/main/java/com/github/davidmoten/grumpy/wms/layer/darkness/SunUtil.java | SunUtil.getSubSolarPoint | public static Position getSubSolarPoint(Calendar time) {
// convert time to Julian Day Number
double jd = TimeUtil.getJulianDayNumber(time);
// Julian centuries since Jan 1, 2000, 12:00 UTC
double T = (jd - 2451545.0) / 36525;
// mean anomaly, degree
double M = 357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048
* T * T * T;
// mean longitude, degree
double L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T * T;
double DL = (1.914600 - 0.004817 * T - 0.000014 * T * T)
* Math.sin(Math.toRadians(M)) + (0.019993 - 0.000101 * T)
* Math.sin(Math.toRadians(2.0 * M)) + 0.000290
* Math.sin(Math.toRadians(3.0 * M));
// true longitude, degree
double L = L0 + DL;
// obliquity eps of ecliptic in degrees:
double eps = 23.0 + 26.0 / 60.0 + 21.448 / 3600.0
- (46.8150 * T + 0.00059 * T * T - 0.001813 * T * T * T)
/ 3600.0;
double X = Math.cos(Math.toRadians(L));
double Y = Math.cos(Math.toRadians(eps)) * Math.sin(Math.toRadians(L));
double Z = Math.sin(Math.toRadians(eps)) * Math.sin(Math.toRadians(L));
double R = Math.sqrt(1.0 - Z * Z);
double delta = Math.toDegrees(Math.atan(Z / R)); // in degrees
double p = Y / (X + R);
double ra = Math.toDegrees(Math.atan(p));
double RA = (24.0 / 180.0) * ra; // in hours
// sidereal time (in hours)
double theta0 = 280.46061837 + 360.98564736629 * (jd - 2451545.0)
+ 0.000387933 * T * T - T * T * T / 38710000.0;
double sidTime = (theta0 % 360) / 15.0;
// lon and lat of sun
double sunHADeg = ((sidTime - RA) * 15.0) % 360.0;
double lon = 0.0;
if (sunHADeg < 180.0) {
lon = -sunHADeg;
} else {
lon = 360.0 - sunHADeg;
}
double lat = delta;
log.info("Sidereal time is " + sidTime + ", Sun RA/Dec is " + RA + "/"
+ delta + ", subSolar lat/long is " + lat + "/" + lon);
return new Position(lat, lon);
} | java | public static Position getSubSolarPoint(Calendar time) {
// convert time to Julian Day Number
double jd = TimeUtil.getJulianDayNumber(time);
// Julian centuries since Jan 1, 2000, 12:00 UTC
double T = (jd - 2451545.0) / 36525;
// mean anomaly, degree
double M = 357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048
* T * T * T;
// mean longitude, degree
double L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T * T;
double DL = (1.914600 - 0.004817 * T - 0.000014 * T * T)
* Math.sin(Math.toRadians(M)) + (0.019993 - 0.000101 * T)
* Math.sin(Math.toRadians(2.0 * M)) + 0.000290
* Math.sin(Math.toRadians(3.0 * M));
// true longitude, degree
double L = L0 + DL;
// obliquity eps of ecliptic in degrees:
double eps = 23.0 + 26.0 / 60.0 + 21.448 / 3600.0
- (46.8150 * T + 0.00059 * T * T - 0.001813 * T * T * T)
/ 3600.0;
double X = Math.cos(Math.toRadians(L));
double Y = Math.cos(Math.toRadians(eps)) * Math.sin(Math.toRadians(L));
double Z = Math.sin(Math.toRadians(eps)) * Math.sin(Math.toRadians(L));
double R = Math.sqrt(1.0 - Z * Z);
double delta = Math.toDegrees(Math.atan(Z / R)); // in degrees
double p = Y / (X + R);
double ra = Math.toDegrees(Math.atan(p));
double RA = (24.0 / 180.0) * ra; // in hours
// sidereal time (in hours)
double theta0 = 280.46061837 + 360.98564736629 * (jd - 2451545.0)
+ 0.000387933 * T * T - T * T * T / 38710000.0;
double sidTime = (theta0 % 360) / 15.0;
// lon and lat of sun
double sunHADeg = ((sidTime - RA) * 15.0) % 360.0;
double lon = 0.0;
if (sunHADeg < 180.0) {
lon = -sunHADeg;
} else {
lon = 360.0 - sunHADeg;
}
double lat = delta;
log.info("Sidereal time is " + sidTime + ", Sun RA/Dec is " + RA + "/"
+ delta + ", subSolar lat/long is " + lat + "/" + lon);
return new Position(lat, lon);
} | [
"public",
"static",
"Position",
"getSubSolarPoint",
"(",
"Calendar",
"time",
")",
"{",
"// convert time to Julian Day Number",
"double",
"jd",
"=",
"TimeUtil",
".",
"getJulianDayNumber",
"(",
"time",
")",
";",
"// Julian centuries since Jan 1, 2000, 12:00 UTC",
"double",
... | Returns the position on the Earth's surface for which the sun appears to
be straight above.
@param time
@return | [
"Returns",
"the",
"position",
"on",
"the",
"Earth",
"s",
"surface",
"for",
"which",
"the",
"sun",
"appears",
"to",
"be",
"straight",
"above",
"."
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-ogc-layers/src/main/java/com/github/davidmoten/grumpy/wms/layer/darkness/SunUtil.java#L82-L143 | train |
threerings/narya | core/src/main/java/com/threerings/presents/dobj/DynamicListener.java | DynamicListener.elementUpdated | public void elementUpdated (ElementUpdatedEvent event)
{
dispatchMethod(event.getName() + "Updated",
new Object[] { event.getIndex(), event.getValue() });
} | java | public void elementUpdated (ElementUpdatedEvent event)
{
dispatchMethod(event.getName() + "Updated",
new Object[] { event.getIndex(), event.getValue() });
} | [
"public",
"void",
"elementUpdated",
"(",
"ElementUpdatedEvent",
"event",
")",
"{",
"dispatchMethod",
"(",
"event",
".",
"getName",
"(",
")",
"+",
"\"Updated\"",
",",
"new",
"Object",
"[",
"]",
"{",
"event",
".",
"getIndex",
"(",
")",
",",
"event",
".",
"... | from interface ElementUpdateListener | [
"from",
"interface",
"ElementUpdateListener"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DynamicListener.java#L68-L72 | train |
threerings/narya | core/src/main/java/com/threerings/presents/dobj/DynamicListener.java | DynamicListener.dispatchMethod | public void dispatchMethod (String name, Object[] arguments)
{
// first check the cache
Method method = _mcache.get(name);
if (method == null) {
// if we haven't already determined this method doesn't exist, try
// to resolve it
if (!_mcache.containsKey(name)) {
_mcache.put(name, method = resolveMethod(name, arguments));
}
}
if (method != null) {
try {
method.invoke(_target, arguments);
} catch (Exception e) {
log.warning("Failed to dispatch event callback " +
name + "(" + StringUtil.toString(arguments) + ").", e);
}
}
} | java | public void dispatchMethod (String name, Object[] arguments)
{
// first check the cache
Method method = _mcache.get(name);
if (method == null) {
// if we haven't already determined this method doesn't exist, try
// to resolve it
if (!_mcache.containsKey(name)) {
_mcache.put(name, method = resolveMethod(name, arguments));
}
}
if (method != null) {
try {
method.invoke(_target, arguments);
} catch (Exception e) {
log.warning("Failed to dispatch event callback " +
name + "(" + StringUtil.toString(arguments) + ").", e);
}
}
} | [
"public",
"void",
"dispatchMethod",
"(",
"String",
"name",
",",
"Object",
"[",
"]",
"arguments",
")",
"{",
"// first check the cache",
"Method",
"method",
"=",
"_mcache",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"//... | Dynamically looks up the method in question on our target and dispatches
an event if it does. | [
"Dynamically",
"looks",
"up",
"the",
"method",
"in",
"question",
"on",
"our",
"target",
"and",
"dispatches",
"an",
"event",
"if",
"it",
"does",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DynamicListener.java#L99-L118 | train |
threerings/narya | core/src/main/java/com/threerings/presents/dobj/DynamicListener.java | DynamicListener.resolveMethod | protected Method resolveMethod (String name, Object[] arguments)
{
Class<?>[] ptypes = new Class<?>[arguments.length];
for (int ii = 0; ii < arguments.length; ii++) {
ptypes[ii] = arguments[ii] == null ?
null : arguments[ii].getClass();
}
try {
return _finder.findMethod(name, ptypes);
} catch (Exception e) {
return null;
}
} | java | protected Method resolveMethod (String name, Object[] arguments)
{
Class<?>[] ptypes = new Class<?>[arguments.length];
for (int ii = 0; ii < arguments.length; ii++) {
ptypes[ii] = arguments[ii] == null ?
null : arguments[ii].getClass();
}
try {
return _finder.findMethod(name, ptypes);
} catch (Exception e) {
return null;
}
} | [
"protected",
"Method",
"resolveMethod",
"(",
"String",
"name",
",",
"Object",
"[",
"]",
"arguments",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"ptypes",
"=",
"new",
"Class",
"<",
"?",
">",
"[",
"arguments",
".",
"length",
"]",
";",
"for",
"(",
"i... | Looks for a method that matches the supplied signature. | [
"Looks",
"for",
"a",
"method",
"that",
"matches",
"the",
"supplied",
"signature",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DynamicListener.java#L123-L135 | train |
threerings/narya | core/src/main/java/com/threerings/presents/net/Transport.java | Transport.getInstance | public static Transport getInstance (Type type, int channel)
{
// were there more parameters in transport objects, it would be better to have a single map
// of instances and use Transport objects as keys (as in examples of the flyweight
// pattern). however, doing it this way avoids the need to create a new object on lookup
if (_unordered == null) {
int length = Type.values().length;
_unordered = new Transport[length];
@SuppressWarnings({ "unchecked" }) HashIntMap<Transport>[] ordered =
(HashIntMap<Transport>[])new HashIntMap<?>[length];
_ordered = ordered;
}
// for unordered transport, we map on the type alone
int idx = type.ordinal();
if (!type.isOrdered()) {
Transport instance = _unordered[idx];
if (instance == null) {
_unordered[idx] = instance = new Transport(type);
}
return instance;
}
// for ordered transport, we map on the type and channel
HashIntMap<Transport> instances = _ordered[idx];
if (instances == null) {
_ordered[idx] = instances = new HashIntMap<Transport>();
}
Transport instance = instances.get(channel);
if (instance == null) {
instances.put(channel, instance = new Transport(type, channel));
}
return instance;
} | java | public static Transport getInstance (Type type, int channel)
{
// were there more parameters in transport objects, it would be better to have a single map
// of instances and use Transport objects as keys (as in examples of the flyweight
// pattern). however, doing it this way avoids the need to create a new object on lookup
if (_unordered == null) {
int length = Type.values().length;
_unordered = new Transport[length];
@SuppressWarnings({ "unchecked" }) HashIntMap<Transport>[] ordered =
(HashIntMap<Transport>[])new HashIntMap<?>[length];
_ordered = ordered;
}
// for unordered transport, we map on the type alone
int idx = type.ordinal();
if (!type.isOrdered()) {
Transport instance = _unordered[idx];
if (instance == null) {
_unordered[idx] = instance = new Transport(type);
}
return instance;
}
// for ordered transport, we map on the type and channel
HashIntMap<Transport> instances = _ordered[idx];
if (instances == null) {
_ordered[idx] = instances = new HashIntMap<Transport>();
}
Transport instance = instances.get(channel);
if (instance == null) {
instances.put(channel, instance = new Transport(type, channel));
}
return instance;
} | [
"public",
"static",
"Transport",
"getInstance",
"(",
"Type",
"type",
",",
"int",
"channel",
")",
"{",
"// were there more parameters in transport objects, it would be better to have a single map",
"// of instances and use Transport objects as keys (as in examples of the flyweight",
"// p... | Returns the shared instance with the specified parameters. | [
"Returns",
"the",
"shared",
"instance",
"with",
"the",
"specified",
"parameters",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/net/Transport.java#L140-L173 | train |
threerings/narya | core/src/main/java/com/threerings/presents/net/Transport.java | Transport.combine | public Transport combine (Transport other)
{
// if the channels are different, we fall back to the default channel
return getInstance(
_type.combine(other._type),
(_channel == other._channel) ? _channel : 0);
} | java | public Transport combine (Transport other)
{
// if the channels are different, we fall back to the default channel
return getInstance(
_type.combine(other._type),
(_channel == other._channel) ? _channel : 0);
} | [
"public",
"Transport",
"combine",
"(",
"Transport",
"other",
")",
"{",
"// if the channels are different, we fall back to the default channel",
"return",
"getInstance",
"(",
"_type",
".",
"combine",
"(",
"other",
".",
"_type",
")",
",",
"(",
"_channel",
"==",
"other",... | Returns a transport that satisfies the requirements of this and the specified other
transport. | [
"Returns",
"a",
"transport",
"that",
"satisfies",
"the",
"requirements",
"of",
"this",
"and",
"the",
"specified",
"other",
"transport",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/net/Transport.java#L212-L218 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java | ChatProvider.broadcast | public void broadcast (Name from, String bundle, String msg, boolean attention, boolean forward)
{
byte levelOrMode = (from != null) ? ChatCodes.BROADCAST_MODE
: (attention ? SystemMessage.ATTENTION : SystemMessage.INFO);
broadcast(from, levelOrMode, bundle, msg, forward);
} | java | public void broadcast (Name from, String bundle, String msg, boolean attention, boolean forward)
{
byte levelOrMode = (from != null) ? ChatCodes.BROADCAST_MODE
: (attention ? SystemMessage.ATTENTION : SystemMessage.INFO);
broadcast(from, levelOrMode, bundle, msg, forward);
} | [
"public",
"void",
"broadcast",
"(",
"Name",
"from",
",",
"String",
"bundle",
",",
"String",
"msg",
",",
"boolean",
"attention",
",",
"boolean",
"forward",
")",
"{",
"byte",
"levelOrMode",
"=",
"(",
"from",
"!=",
"null",
")",
"?",
"ChatCodes",
".",
"BROAD... | Broadcasts the specified message to all place objects in the system.
@param from the user the broadcast is from, or null to send the message as a system message.
@param bundle the bundle, or null if the message needs no translation.
@param msg the content of the message to broadcast.
@param attention if true, the message is sent as ATTENTION level, otherwise as INFO. Ignored
if from is non-null.
@param forward if true, forward this broadcast on to any registered chat forwarder, if
false, deliver it only locally on this server. | [
"Broadcasts",
"the",
"specified",
"message",
"to",
"all",
"place",
"objects",
"in",
"the",
"system",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L186-L191 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java | ChatProvider.broadcast | public void broadcast (Name from, byte levelOrMode, String bundle, String msg, boolean forward)
{
if (_broadcastObject != null) {
broadcastTo(_broadcastObject, from, levelOrMode, bundle, msg);
} else {
for (Iterator<PlaceObject> iter = _plreg.enumeratePlaces(); iter.hasNext(); ) {
PlaceObject plobj = iter.next();
if (plobj.shouldBroadcast()) {
broadcastTo(plobj, from, levelOrMode, bundle, msg);
}
}
}
if (forward && _chatForwarder != null) {
_chatForwarder.forwardBroadcast(from, levelOrMode, bundle, msg);
}
} | java | public void broadcast (Name from, byte levelOrMode, String bundle, String msg, boolean forward)
{
if (_broadcastObject != null) {
broadcastTo(_broadcastObject, from, levelOrMode, bundle, msg);
} else {
for (Iterator<PlaceObject> iter = _plreg.enumeratePlaces(); iter.hasNext(); ) {
PlaceObject plobj = iter.next();
if (plobj.shouldBroadcast()) {
broadcastTo(plobj, from, levelOrMode, bundle, msg);
}
}
}
if (forward && _chatForwarder != null) {
_chatForwarder.forwardBroadcast(from, levelOrMode, bundle, msg);
}
} | [
"public",
"void",
"broadcast",
"(",
"Name",
"from",
",",
"byte",
"levelOrMode",
",",
"String",
"bundle",
",",
"String",
"msg",
",",
"boolean",
"forward",
")",
"{",
"if",
"(",
"_broadcastObject",
"!=",
"null",
")",
"{",
"broadcastTo",
"(",
"_broadcastObject",... | Broadcast with support for a customizable level or mode.
@param levelOrMode if from is null, it's an attentionLevel, else it's a mode code. | [
"Broadcast",
"with",
"support",
"for",
"a",
"customizable",
"level",
"or",
"mode",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L197-L214 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java | ChatProvider.deliverTell | public void deliverTell (UserMessage message, Name target, TellListener listener)
throws InvocationException
{
// make sure the target user is online
BodyObject tobj = _locator.lookupBody(target);
if (tobj == null) {
// if we have a forwarder configured, try forwarding the tell
if (_chatForwarder != null && _chatForwarder.forwardTell(message, target, listener)) {
return;
}
throw new InvocationException(ChatCodes.USER_NOT_ONLINE);
}
if (tobj.status == OccupantInfo.DISCONNECTED) {
String errmsg = MessageBundle.compose(
ChatCodes.USER_DISCONNECTED, TimeUtil.getTimeOrderString(
System.currentTimeMillis() - tobj.getLocal(BodyLocal.class).statusTime,
TimeUtil.SECOND));
throw new InvocationException(errmsg);
}
// deliver a tell notification to the target player
deliverTell(tobj, message);
// let the teller know it went ok
long idle = 0L;
if (tobj.status == OccupantInfo.IDLE) {
idle = System.currentTimeMillis() - tobj.getLocal(BodyLocal.class).statusTime;
}
String awayMessage = null;
if (!StringUtil.isBlank(tobj.awayMessage)) {
awayMessage = tobj.awayMessage;
}
listener.tellSucceeded(idle, awayMessage);
} | java | public void deliverTell (UserMessage message, Name target, TellListener listener)
throws InvocationException
{
// make sure the target user is online
BodyObject tobj = _locator.lookupBody(target);
if (tobj == null) {
// if we have a forwarder configured, try forwarding the tell
if (_chatForwarder != null && _chatForwarder.forwardTell(message, target, listener)) {
return;
}
throw new InvocationException(ChatCodes.USER_NOT_ONLINE);
}
if (tobj.status == OccupantInfo.DISCONNECTED) {
String errmsg = MessageBundle.compose(
ChatCodes.USER_DISCONNECTED, TimeUtil.getTimeOrderString(
System.currentTimeMillis() - tobj.getLocal(BodyLocal.class).statusTime,
TimeUtil.SECOND));
throw new InvocationException(errmsg);
}
// deliver a tell notification to the target player
deliverTell(tobj, message);
// let the teller know it went ok
long idle = 0L;
if (tobj.status == OccupantInfo.IDLE) {
idle = System.currentTimeMillis() - tobj.getLocal(BodyLocal.class).statusTime;
}
String awayMessage = null;
if (!StringUtil.isBlank(tobj.awayMessage)) {
awayMessage = tobj.awayMessage;
}
listener.tellSucceeded(idle, awayMessage);
} | [
"public",
"void",
"deliverTell",
"(",
"UserMessage",
"message",
",",
"Name",
"target",
",",
"TellListener",
"listener",
")",
"throws",
"InvocationException",
"{",
"// make sure the target user is online",
"BodyObject",
"tobj",
"=",
"_locator",
".",
"lookupBody",
"(",
... | Delivers a tell message to the specified target and notifies the supplied listener of the
result. It is assumed that the teller has already been permissions checked. | [
"Delivers",
"a",
"tell",
"message",
"to",
"the",
"specified",
"target",
"and",
"notifies",
"the",
"supplied",
"listener",
"of",
"the",
"result",
".",
"It",
"is",
"assumed",
"that",
"the",
"teller",
"has",
"already",
"been",
"permissions",
"checked",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L220-L254 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java | ChatProvider.deliverTell | public void deliverTell (BodyObject target, UserMessage message)
{
SpeakUtil.sendMessage(target, message);
// note that the teller "heard" what they said
SpeakUtil.noteMessage(target, message.speaker, message);
} | java | public void deliverTell (BodyObject target, UserMessage message)
{
SpeakUtil.sendMessage(target, message);
// note that the teller "heard" what they said
SpeakUtil.noteMessage(target, message.speaker, message);
} | [
"public",
"void",
"deliverTell",
"(",
"BodyObject",
"target",
",",
"UserMessage",
"message",
")",
"{",
"SpeakUtil",
".",
"sendMessage",
"(",
"target",
",",
"message",
")",
";",
"// note that the teller \"heard\" what they said",
"SpeakUtil",
".",
"noteMessage",
"(",
... | Delivers a tell notification to the specified target player. It is assumed that the message
is coming from some server entity and need not be permissions checked or notified of the
result. | [
"Delivers",
"a",
"tell",
"notification",
"to",
"the",
"specified",
"target",
"player",
".",
"It",
"is",
"assumed",
"that",
"the",
"message",
"is",
"coming",
"from",
"some",
"server",
"entity",
"and",
"need",
"not",
"be",
"permissions",
"checked",
"or",
"noti... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L261-L267 | train |
threerings/narya | core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java | ChatProvider.broadcastTo | protected void broadcastTo (
DObject object, Name from, byte levelOrMode, String bundle, String msg)
{
if (from == null) {
SpeakUtil.sendSystem(object, bundle, msg, levelOrMode /* level */);
} else {
SpeakUtil.sendSpeak(object, from, bundle, msg, levelOrMode /* mode */);
}
} | java | protected void broadcastTo (
DObject object, Name from, byte levelOrMode, String bundle, String msg)
{
if (from == null) {
SpeakUtil.sendSystem(object, bundle, msg, levelOrMode /* level */);
} else {
SpeakUtil.sendSpeak(object, from, bundle, msg, levelOrMode /* mode */);
}
} | [
"protected",
"void",
"broadcastTo",
"(",
"DObject",
"object",
",",
"Name",
"from",
",",
"byte",
"levelOrMode",
",",
"String",
"bundle",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"from",
"==",
"null",
")",
"{",
"SpeakUtil",
".",
"sendSystem",
"(",
"objec... | Direct a broadcast to the specified object. | [
"Direct",
"a",
"broadcast",
"to",
"the",
"specified",
"object",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L280-L289 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java | PresentsConnectionManager.appendReport | public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset)
{
PresentsConMgrStats stats = getStats();
long eventCount = stats.eventCount - _lastStats.eventCount;
int connects = stats.connects - _lastStats.connects;
int disconnects = stats.disconnects - _lastStats.disconnects;
int closes = stats.closes - _lastStats.closes;
long bytesIn = stats.bytesIn - _lastStats.bytesIn;
long bytesOut = stats.bytesOut - _lastStats.bytesOut;
long msgsIn = stats.msgsIn - _lastStats.msgsIn;
long msgsOut = stats.msgsOut - _lastStats.msgsOut;
if (reset) {
_lastStats = stats;
}
// make sure we don't div0 if this method somehow gets called twice in
// the same millisecond
sinceLast = Math.max(sinceLast, 1L);
report.append("* presents.net.ConnectionManager:\n");
report.append("- Network connections: ");
report.append(stats.connectionCount).append(" connections, ");
report.append(stats.handlerCount).append(" handlers\n");
report.append("- Network activity: ");
report.append(eventCount).append(" events, ");
report.append(connects).append(" connects, ");
report.append(disconnects).append(" disconnects, ");
report.append(closes).append(" closes\n");
report.append("- Network input: ");
report.append(bytesIn).append(" bytes, ");
report.append(msgsIn).append(" msgs, ");
report.append(msgsIn*1000/sinceLast).append(" mps, ");
long avgIn = (msgsIn == 0) ? 0 : (bytesIn/msgsIn);
report.append(avgIn).append(" avg size, ");
report.append(bytesIn*1000/sinceLast).append(" bps\n");
report.append("- Network output: ");
report.append(bytesOut).append(" bytes, ");
report.append(msgsOut).append(" msgs, ");
report.append(msgsOut*1000/sinceLast).append(" mps, ");
long avgOut = (msgsOut == 0) ? 0 : (bytesOut/msgsOut);
report.append(avgOut).append(" avg size, ");
report.append(bytesOut*1000/sinceLast).append(" bps\n");
} | java | public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset)
{
PresentsConMgrStats stats = getStats();
long eventCount = stats.eventCount - _lastStats.eventCount;
int connects = stats.connects - _lastStats.connects;
int disconnects = stats.disconnects - _lastStats.disconnects;
int closes = stats.closes - _lastStats.closes;
long bytesIn = stats.bytesIn - _lastStats.bytesIn;
long bytesOut = stats.bytesOut - _lastStats.bytesOut;
long msgsIn = stats.msgsIn - _lastStats.msgsIn;
long msgsOut = stats.msgsOut - _lastStats.msgsOut;
if (reset) {
_lastStats = stats;
}
// make sure we don't div0 if this method somehow gets called twice in
// the same millisecond
sinceLast = Math.max(sinceLast, 1L);
report.append("* presents.net.ConnectionManager:\n");
report.append("- Network connections: ");
report.append(stats.connectionCount).append(" connections, ");
report.append(stats.handlerCount).append(" handlers\n");
report.append("- Network activity: ");
report.append(eventCount).append(" events, ");
report.append(connects).append(" connects, ");
report.append(disconnects).append(" disconnects, ");
report.append(closes).append(" closes\n");
report.append("- Network input: ");
report.append(bytesIn).append(" bytes, ");
report.append(msgsIn).append(" msgs, ");
report.append(msgsIn*1000/sinceLast).append(" mps, ");
long avgIn = (msgsIn == 0) ? 0 : (bytesIn/msgsIn);
report.append(avgIn).append(" avg size, ");
report.append(bytesIn*1000/sinceLast).append(" bps\n");
report.append("- Network output: ");
report.append(bytesOut).append(" bytes, ");
report.append(msgsOut).append(" msgs, ");
report.append(msgsOut*1000/sinceLast).append(" mps, ");
long avgOut = (msgsOut == 0) ? 0 : (bytesOut/msgsOut);
report.append(avgOut).append(" avg size, ");
report.append(bytesOut*1000/sinceLast).append(" bps\n");
} | [
"public",
"void",
"appendReport",
"(",
"StringBuilder",
"report",
",",
"long",
"now",
",",
"long",
"sinceLast",
",",
"boolean",
"reset",
")",
"{",
"PresentsConMgrStats",
"stats",
"=",
"getStats",
"(",
")",
";",
"long",
"eventCount",
"=",
"stats",
".",
"event... | from interface ReportManager.Reporter | [
"from",
"interface",
"ReportManager",
".",
"Reporter"
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java#L127-L169 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java | PresentsConnectionManager.setPrivateKey | public boolean setPrivateKey (PrivateKey key)
{
if (SecureUtil.ciphersSupported(key)) {
_privateKey = key;
return true;
}
return false;
} | java | public boolean setPrivateKey (PrivateKey key)
{
if (SecureUtil.ciphersSupported(key)) {
_privateKey = key;
return true;
}
return false;
} | [
"public",
"boolean",
"setPrivateKey",
"(",
"PrivateKey",
"key",
")",
"{",
"if",
"(",
"SecureUtil",
".",
"ciphersSupported",
"(",
"key",
")",
")",
"{",
"_privateKey",
"=",
"key",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Sets the private key if the ciphers are supported.
@return true if the key is set | [
"Sets",
"the",
"private",
"key",
"if",
"the",
"ciphers",
"are",
"supported",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java#L185-L192 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java | PresentsConnectionManager.handleDatagram | protected int handleDatagram (DatagramChannel listener, long when)
{
InetSocketAddress source;
_databuf.clear();
try {
source = (InetSocketAddress)listener.receive(_databuf);
} catch (IOException ioe) {
log.warning("Failure receiving datagram.", ioe);
return 0;
}
// make sure we actually read a packet
if (source == null) {
log.info("Psych! Got READ_READY, but no datagram.");
return 0;
}
// flip the buffer and record the size (which must be at least 14 to contain the connection
// id, authentication hash, and a class reference)
int size = _databuf.flip().remaining();
if (size < 14) {
log.warning("Received undersized datagram", "source", source, "size", size);
return 0;
}
// the first four bytes are the connection id
int connectionId = _databuf.getInt();
Connection conn = _connections.get(connectionId);
if (conn != null) {
((PresentsConnection)conn).handleDatagram(source, listener, _databuf, when);
} else {
log.debug("Received datagram for unknown connection", "id", connectionId,
"source", source);
}
return size;
} | java | protected int handleDatagram (DatagramChannel listener, long when)
{
InetSocketAddress source;
_databuf.clear();
try {
source = (InetSocketAddress)listener.receive(_databuf);
} catch (IOException ioe) {
log.warning("Failure receiving datagram.", ioe);
return 0;
}
// make sure we actually read a packet
if (source == null) {
log.info("Psych! Got READ_READY, but no datagram.");
return 0;
}
// flip the buffer and record the size (which must be at least 14 to contain the connection
// id, authentication hash, and a class reference)
int size = _databuf.flip().remaining();
if (size < 14) {
log.warning("Received undersized datagram", "source", source, "size", size);
return 0;
}
// the first four bytes are the connection id
int connectionId = _databuf.getInt();
Connection conn = _connections.get(connectionId);
if (conn != null) {
((PresentsConnection)conn).handleDatagram(source, listener, _databuf, when);
} else {
log.debug("Received datagram for unknown connection", "id", connectionId,
"source", source);
}
return size;
} | [
"protected",
"int",
"handleDatagram",
"(",
"DatagramChannel",
"listener",
",",
"long",
"when",
")",
"{",
"InetSocketAddress",
"source",
";",
"_databuf",
".",
"clear",
"(",
")",
";",
"try",
"{",
"source",
"=",
"(",
"InetSocketAddress",
")",
"listener",
".",
"... | Called when a datagram message is ready to be read off its channel. | [
"Called",
"when",
"a",
"datagram",
"message",
"is",
"ready",
"to",
"be",
"read",
"off",
"its",
"channel",
"."
] | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java#L215-L251 | train |
threerings/narya | core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java | PresentsConnectionManager.openOutgoingConnection | public void openOutgoingConnection (Connection conn, String hostname, int port)
throws IOException
{
// create a socket channel to use for this connection, initialize it and queue it up to
// have the non-blocking connect process started
SocketChannel sockchan = SocketChannel.open();
sockchan.configureBlocking(false);
conn.init(this, sockchan, System.currentTimeMillis());
_connectq.append(Tuple.newTuple(conn, new InetSocketAddress(hostname, port)));
} | java | public void openOutgoingConnection (Connection conn, String hostname, int port)
throws IOException
{
// create a socket channel to use for this connection, initialize it and queue it up to
// have the non-blocking connect process started
SocketChannel sockchan = SocketChannel.open();
sockchan.configureBlocking(false);
conn.init(this, sockchan, System.currentTimeMillis());
_connectq.append(Tuple.newTuple(conn, new InetSocketAddress(hostname, port)));
} | [
"public",
"void",
"openOutgoingConnection",
"(",
"Connection",
"conn",
",",
"String",
"hostname",
",",
"int",
"port",
")",
"throws",
"IOException",
"{",
"// create a socket channel to use for this connection, initialize it and queue it up to",
"// have the non-blocking connect proc... | Opens an outgoing connection to the supplied address. The connection will be opened in a
non-blocking manner and added to the connection manager's select set. Messages posted to the
connection prior to it being actually connected to its destination will remain in the queue.
If the connection fails those messages will be dropped.
@param conn the connection to be initialized and opened. Callers may want to provide a
{@link Connection} derived class so that they may intercept calldown methods.
@param hostname the hostname of the server to which to connect.
@param port the port on which to connect to the server.
@exception IOException thrown if an error occurs creating our socket. Everything else
happens asynchronously. If the connection attempt fails, the Connection will be notified via
{@link Connection#networkFailure}. | [
"Opens",
"an",
"outgoing",
"connection",
"to",
"the",
"supplied",
"address",
".",
"The",
"connection",
"will",
"be",
"opened",
"in",
"a",
"non",
"-",
"blocking",
"manner",
"and",
"added",
"to",
"the",
"connection",
"manager",
"s",
"select",
"set",
".",
"Me... | 5b01edc8850ed0c32d004b4049e1ac4a02027ede | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/net/PresentsConnectionManager.java#L369-L378 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.