本文整理匯總了Java中org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect類的典型用法代碼示例。如果您正苦於以下問題:Java OnWebSocketConnect類的具體用法?Java OnWebSocketConnect怎麽用?Java OnWebSocketConnect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OnWebSocketConnect類屬於org.eclipse.jetty.websocket.api.annotations包,在下文中一共展示了OnWebSocketConnect類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
/**
* Callback hook for Connection open events.
*
* @param session the user session which is opened.
*/
@OnWebSocketConnect
public void onConnect(Session session) {
this.session = session;
this.futureSession = null; // don't need this anymore
this.addr = session.getRemoteAddress().getAddress();
this.remotePort = session.getRemoteAddress().getPort();
this.localAddr = session.getLocalAddress().getAddress();
this.localPort = session.getLocalAddress().getPort();
this.path = session.getUpgradeRequest().getRequestURI().getPath();
if (session.getUpgradeRequest() instanceof ClientUpgradeRequest) {
this.key = ((ClientUpgradeRequest)session.getUpgradeRequest()).getKey();
}
else {
this.key = session.getUpgradeRequest().getHeader("Sec-WebSocket-Key");
}
if (log.isLoggable(Level.INFO))
log.log(Level.INFO,"Connected with "+((addr==null)?"<null>":addr.toString())+" through local address "+localAddr.getHostAddress());
pool.addSession(this);
pool.getInclusionCallback().onStartConnection(this);
}
示例2: handleConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void handleConnect(Session session) {
String uri = session.getUpgradeRequest().getRequestURI().getPath();
LOG.debug("websocket connect: " + uri);
//create session
this.session = session;
this.bindingSession = new cn.batchfile.getty.binding.socket.Session(session);
//find hanlder
WebSocketHandler handler = getHandler(uri);
if (handler == null) {
session.getUpgradeResponse().setStatusCode(404);
return;
}
//get file
String file = handler.getConnect();
if (StringUtils.isEmpty(file)) {
return;
}
bindAndRun(handler, file, null, null);
}
示例3: connect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void connect(Session session) {
WebSocketSession webSocketSession = (WebSocketSession)session;
if (webSocketSession == null) {
LOG.info("Session was not WebSocketSession");
return;
}
Map<String, String> query = query(webSocketSession.getRequestURI().getQuery());
SocketIOSession s = query.get("sid")
.flatMap(sessions::get)
.getOrElse(() -> {
LOG.warn("Could not find session for sid, ignoring");
return null;
});
if (s != null) {
s.setWebsocketSession(session);
}
}
示例4: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws Exception {
this.session = session;
socketHealthService.register(this);
LOGGER.debug("{} connected", sessionName());
session.getRemote().sendString(consoleLogCharsetJSONMessage);
long start = parseStartLine(session.getUpgradeRequest());
LOGGER.debug("{} sending logs for {} starting at line {}.", sessionName(), jobIdentifier, start);
try {
handler.process(this, jobIdentifier, start);
} catch (IOException e) {
if ("Connection output is closed".equals(e.getMessage())) {
LOGGER.debug("{} client (likely, browser) closed connection prematurely.", sessionName());
close(); // for good measure
} else {
throw e;
}
}
}
示例5: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
logger.info("---- onConnect");
try {
String subStr = "{"
+ " \"command\" : \"subscribe\","
+ " \"req.id\" : \"" + UUID.randomUUID().toString() + "\","
+ " \"event\" : \"*\","
+ " \"session_id\" : \"" + protocol.getSessionId() + "\""
+ "}";
session.getRemote().sendString(subStr);
String gid = protocol.getGroupId();
if (gid != null) {
subStr = "{"
+ " \"command\" : \"subscribe\","
+ " \"req.id\" : \"" + UUID.randomUUID().toString() + "\","
+ " \"event\" : \"*\","
+ " \"group_id\" : \"" + "1" + "\""
+ "}";
session.getRemote().sendString(subStr);
}
connected = true;
} catch (IOException ex) {
java.util.logging.Logger.getLogger(PushReceiver.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例6: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session newWebSocket) {
this.session = newWebSocket;
log.info("Broker Client WebSocket open: " + session.getRemoteAddress());
session.setIdleTimeout(CLIENT_WS_IDLE_TIMEOUT_MS);
Broadcaster.getInstance().subscribe(this);
onConnectQuerier.queryApiOnClientConnect();
}
示例7: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws AuthenticationException
{
Map<String, List<String>> params = session.getUpgradeRequest().getParameterMap();
List<String> keys = params.get("key");
if (keys == null || keys.size() != 1 || !keys.get(0).equals(NMOConfiguration.INSTANCE.integrations.webUI.ultiwakerAPI.apiSecurityKey))
{
throw new AuthenticationException("Not authorized");
}
this.session = session;
this.connectionIP = session.getRemoteAddress().getAddress().toString();
connections.add(this);
log.info("UWAPI connect from " + this.connectionIP);
}
示例8: OnOpen
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void OnOpen(Session sess)
{
LOG.info("OnOpen({})",sess);
this._session = sess;
_protocolEngine.OnOpen(this);
_scheduler.scheduleAtFixedRate(
new TestRequest(this),
_testRequestDelayInSeconds,
_testRequestDelayInSeconds,
TimeUnit.SECONDS
);
}
開發者ID:djalmasantos,項目名稱:blinktrade_api_java_client_sample,代碼行數:14,代碼來源:WebSocketClientConnection.java
示例9: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session user) throws Exception
{
System.out.println("Connected " + user.getRemoteAddress().getHostString() );
if (RobotDriver.master == null) RobotDriver.master = user;
RobotDriver.userSet.add(user);
if (RobotDriver.robot instanceof SideIRSensors){
RobotDriver.broadcastRightIRSensorMessage(((SideIRSensors)RobotDriver.robot).getRightIRSensor().isTriggered());
RobotDriver.broadcastLeftIRSensorMessage(((SideIRSensors)RobotDriver.robot).getLeftIRSensor().isTriggered());
}
}
示例10: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws InterruptedException {
active = true;
System.out.println("Trying to Connect to: " + session.getRemoteAddress().getAddress());
try {
session.getRemote().sendString("REG|videosws|samtec");
session.getRemote().sendString("MSG|videosws|videosws|U");
}catch (IOException e) {
e.printStackTrace();
}
}
示例11: connected
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
/**
* Invoked whenever a new connection is established. Configures the session and
* stashes it in the SESSIONS map.
*
* @param session Session associated with the new connection.
*/
@OnWebSocketConnect
public void connected(Session session) {
session.getPolicy().setMaxTextMessageSize(Config.sharedConfig().getApi().getMaxMessageSize());
session.getPolicy().setMaxBinaryMessageSize(Config.sharedConfig().getApi().getMaxMessageSize());
sessions.add(session);
LOGGER.debug("New session {} connected!", session.getRemoteAddress().toString());
}
示例12: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
System.out.println("Connect: " + session.getRemoteAddress().getAddress());
try {
session.getRemote().sendString("Hello Client");
} catch (Exception e) {
System.out.println("Exception "+ e);
}
}
示例13: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
LOG.trace("onConnect {}", session);
this.session = session;
this.connectionKey = UUID.randomUUID().toString();
sync.addSocket(this);
}
示例14: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) throws IOException {
LOG.debug("Ryzom WebSocket is now connected");
LOG.trace("Session is {}", session);
this.session = session;
this.timestamp = System.currentTimeMillis();
}
示例15: onConnect
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; //導入依賴的package包/類
@OnWebSocketConnect
public void onConnect(Session session) {
System.out.printf("Got connect: %s%n", session);
this.session = session;
try {
Future<Void> fut;
fut = session.getRemote().sendStringByFuture("Hello");
fut.get(2, TimeUnit.SECONDS);
fut = session.getRemote().sendStringByFuture("Thanks for the conversation.");
fut.get(2, TimeUnit.SECONDS);
session.close(StatusCode.NORMAL, "I'm done");
} catch (Throwable t) {
t.printStackTrace();
}
}