本文整理汇总了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();
}
}