I'm only using the basic grizzly framework module and building an server.
I have selectionKeys which (hopefully) often last 12 hours.
With each connection I need to store an Integer (project_id).
This Integer will then be retrieved with code like:
//iterate over all existings connections and find
// keys with specific ids.
selector.selectNow()
Set<SelectionKey> selectionKeys = tCPSelectorHandler.keys();
for (SelectionKey key : selectionKeys) {
if(key.valid()
// Get Integer out of maybe ThreadAttachment key.attachment();
}
}
I am a little afraid that Grizzly might overwrite the attachment
in my keys.
Maybe its better to store the integers somewhere else together with selectorKey.hashcode() and hope that two keys will never have the same
hashcodes...
So....
What is the best way to attach something to an selectorKey or in other
words what is the pendant to
AttributeHolder connectionAttrs =
ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);
Many Greetings John
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser