synchronized LSPProcess createProcess(String wsKey, String lang, RemoteEndpoint.Basic remoteEndpoint, String ownerSessionId) throws LSPException {
String procKey = processKey(wsKey, lang);
String rpcType = langContexts.get(lang).getRpcType();
String wsKeyElem[] = wsKey.split(WS_KEY_DELIMITER,3);
disconnect(lang, ownerSessionId);
LSPProcess lspProcess = new LSPProcess(wsKeyElem, lang, langContexts.get(lang).getProcessBuilder(wsKeyElem), remoteEndpoint, ownerSessionId);
switch(rpcType) {
case ENV_IPC_SOCKET:
socketEnv(lspProcess, LangServerCtx.LangPrefix(lang));
break;
case ENV_IPC_PIPES:
pipeEnv(lspProcess, LangServerCtx.LangPrefix(lang));
break;
case ENV_IPC_CLIENT:
clientSocketEnv(lspProcess, LangServerCtx.LangPrefix(lang));
break;
default:
streamEnv(lspProcess);
}
lspProcesses.put(procKey, lspProcess);
return lspProcess;
}
java类javax.websocket.RemoteEndpoint.Basic的实例源码
LSPProcessManager.java 文件源码
项目:cloud-language-servers-container
阅读 26
收藏 0
点赞 0
评论 0
GameViewerSocket.java 文件源码
项目:script-wars
阅读 27
收藏 0
点赞 0
评论 0
@OnOpen
public void open(@PathParam("gametype") String gameID, Session session) throws IOException {
type = GameType.getGameType(gameID);
if(type == null) {
session.close(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "Invalid game type"));
return;
}
Basic sender = session.getBasicRemote();
viewer = data -> {
synchronized(session) {
if(session.isOpen())
try { sender.sendBinary(data); } catch (IOException e) {}
}
};
DisplayHandler.addGlobalViewer(viewer);
}
AbstractEndpointTest.java 文件源码
项目:cito
阅读 30
收藏 0
点赞 0
评论 0
@Test
public void onError() throws IOException, EncodeException {
final Session session = mock(Session.class);
when(session.getId()).thenReturn("sessionId");
final Throwable cause = new Throwable();
when(this.errorEvent.select(OnError.Literal.onError())).thenReturn(this.errorEvent);
final Basic basic = mock(Basic.class);
when(session.getBasicRemote()).thenReturn(basic);
this.endpoint.onError(session, cause);
verify(session).getId();
verify(session).getUserPrincipal();
verify(this.log).warn(eq("WebSocket error. [id={},principle={},errorId={}]"), eq("sessionId"), isNull(), anyString(), eq(cause));
verify(this.errorEvent).select(OnError.Literal.onError());
verify(this.errorEvent).fire(cause);
verify(session).getBasicRemote();
verify(basic).sendObject(any(Frame.class));
verify(session).close(any(CloseReason.class));
verifyNoMoreInteractions(session, basic);
}
SessionRegistryTest.java 文件源码
项目:cito
阅读 30
收藏 0
点赞 0
评论 0
@Test
public void fromBroker() throws IOException, EncodeException {
final Message msg = mock(Message.class);
when(msg.sessionId()).thenReturn("sessionId");
final Frame frame = mock(Frame.class);
when(msg.frame()).thenReturn(frame);
when(frame.command()).thenReturn(Command.MESSAGE);
final Session session = Mockito.mock(Session.class);
getSessionMap().put("sessionId", session);
getPrincipalSessionMap().put(NULL_PRINCIPLE, new HashSet<>(singleton(session)));
final Basic basic = mock(Basic.class);
when(session.getBasicRemote()).thenReturn(basic);
this.registry.fromBroker(msg);
verify(msg).sessionId();
verify(msg).frame();
verify(frame, times(2)).command();
verify(this.log).debug("Sending message to client. [sessionId={},command={}]", "sessionId", Command.MESSAGE);
verify(session).getBasicRemote();
verify(basic).sendObject(frame);
verifyNoMoreInteractions(msg, frame, session, basic);
}
SessionRegistryTest.java 文件源码
项目:cito
阅读 30
收藏 0
点赞 0
评论 0
@Test
public void fromBroker_ioe() throws IOException, EncodeException {
final Message msg = mock(Message.class);
when(msg.sessionId()).thenReturn("sessionId");
final Frame frame = mock(Frame.class);
when(msg.frame()).thenReturn(frame);
when(frame.command()).thenReturn(Command.MESSAGE);
final Session session = Mockito.mock(Session.class);
getSessionMap().put("sessionId", session);
getPrincipalSessionMap().put(NULL_PRINCIPLE, new HashSet<>(singleton(session)));
final Basic basic = mock(Basic.class);
when(session.getBasicRemote()).thenReturn(basic);
final IOException ioe = new IOException();
doThrow(ioe).when(basic).sendObject(frame);
this.registry.fromBroker(msg);
verify(msg).sessionId();
verify(msg).frame();
verify(frame, times(3)).command();
verify(this.log).debug("Sending message to client. [sessionId={},command={}]", "sessionId", Command.MESSAGE);
verify(session).getBasicRemote();
verify(basic).sendObject(frame);
verify(this.log).error("Unable to send message! [sessionid={},command={}]", "sessionId", Command.MESSAGE, ioe);
verifyNoMoreInteractions(msg, frame, session, basic);
}
WebSocketHelper.java 文件源码
项目:hawkular-commons
阅读 29
收藏 0
点赞 0
评论 0
public long copyInputToOutput() throws IOException {
Basic basicRemote = session.getBasicRemote();
OutputStream outputStream = basicRemote.getSendStream();
try {
// slurp the input stream data and send directly to the output stream
byte[] buf = new byte[4096];
long totalBytesCopied = 0L;
while (true) {
int numRead = inputStream.read(buf);
if (numRead == -1) {
break;
}
outputStream.write(buf, 0, numRead);
totalBytesCopied += numRead;
}
return totalBytesCopied;
} finally {
try {
outputStream.close();
} finally {
inputStream.close();
}
}
}
LSPProcessManager.java 文件源码
项目:cloud-language-servers-container
阅读 34
收藏 0
点赞 0
评论 0
LSPProcess(String wsKeyElem[], String lang, ProcessBuilder pb, Basic remoteEndpoint, String ownerSessionId) {
this.pb = pb;
this.remoteEndpoint = remoteEndpoint;
this.projPathElem = "/" + String.join("/", Arrays.copyOfRange(wsKeyElem,1,wsKeyElem.length));
this.lang = lang;
this.ownerSessionId = ownerSessionId;
}
TesterFirehoseServer.java 文件源码
项目:tomcat7
阅读 35
收藏 0
点赞 0
评论 0
@OnMessage
public void onMessage(Session session, String msg) throws IOException {
if (started) {
return;
}
synchronized (this) {
if (started) {
return;
} else {
started = true;
}
}
System.out.println("Received " + msg + ", now sending data");
session.getUserProperties().put(
"org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT",
Long.valueOf(SEND_TIME_OUT_MILLIS));
Basic remote = session.getBasicRemote();
remote.setBatchingAllowed(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
remote.sendText(MESSAGE);
if (i % (MESSAGE_COUNT * 0.4) == 0) {
remote.setBatchingAllowed(false);
remote.setBatchingAllowed(true);
}
}
// Flushing should happen automatically on session close
session.close();
}
HelloWebSocketTest.java 文件源码
项目:minijax
阅读 25
收藏 0
点赞 0
评论 0
private Session getSession() {
final Basic basicRemote = mock(Basic.class);
final Session session = mock(Session.class);
when(session.getBasicRemote()).thenReturn(basicRemote);
return session;
}
TesterFirehoseServer.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 38
收藏 0
点赞 0
评论 0
@OnMessage
public void onMessage(Session session, String msg) throws IOException {
if (started) {
return;
}
synchronized (this) {
if (started) {
return;
} else {
started = true;
}
}
System.out.println("Received " + msg + ", now sending data");
session.getUserProperties().put(
"org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT",
Long.valueOf(SEND_TIME_OUT_MILLIS));
Basic remote = session.getBasicRemote();
remote.setBatchingAllowed(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
remote.sendText(MESSAGE);
if (i % (MESSAGE_COUNT * 0.4) == 0) {
remote.setBatchingAllowed(false);
remote.setBatchingAllowed(true);
}
}
// Flushing should happen automatically on session close
session.close();
}
PurifinityServerSocketIT.java 文件源码
项目:Purifinity
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void test() throws Exception {
Session session = webSocketContainer.connectToServer(this, new URI(
"ws://localhost:8080/purifinityserver/socket/server"));
try {
Basic basic = session.getBasicRemote();
basic.sendText("getStatus");
} finally {
session.close(new CloseReason(CloseCodes.GOING_AWAY,
"We are done..."));
}
Thread.sleep(5000);
}
TesterFirehoseServer.java 文件源码
项目:class-guard
阅读 36
收藏 0
点赞 0
评论 0
@OnMessage
public void onMessage(Session session, String msg) throws IOException {
if (started) {
return;
}
synchronized (this) {
if (started) {
return;
} else {
started = true;
}
}
System.out.println("Received " + msg + ", now sending data");
session.getUserProperties().put(
"org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT",
Long.valueOf(SEND_TIME_OUT_MILLIS));
Basic remote = session.getBasicRemote();
remote.setBatchingAllowed(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
remote.sendText(MESSAGE);
}
// Ensure remaining messages are flushed
remote.setBatchingAllowed(false);
}
TesterFirehoseServer.java 文件源码
项目:apache-tomcat-7.0.57
阅读 35
收藏 0
点赞 0
评论 0
@OnMessage
public void onMessage(Session session, String msg) throws IOException {
if (started) {
return;
}
synchronized (this) {
if (started) {
return;
} else {
started = true;
}
}
System.out.println("Received " + msg + ", now sending data");
session.getUserProperties().put(
"org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT",
Long.valueOf(SEND_TIME_OUT_MILLIS));
Basic remote = session.getBasicRemote();
remote.setBatchingAllowed(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
remote.sendText(MESSAGE);
}
// Ensure remaining messages are flushed
remote.setBatchingAllowed(false);
}
TesterFirehoseServer.java 文件源码
项目:apache-tomcat-7.0.57
阅读 30
收藏 0
点赞 0
评论 0
@OnMessage
public void onMessage(Session session, String msg) throws IOException {
if (started) {
return;
}
synchronized (this) {
if (started) {
return;
} else {
started = true;
}
}
System.out.println("Received " + msg + ", now sending data");
session.getUserProperties().put(
"org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT",
Long.valueOf(SEND_TIME_OUT_MILLIS));
Basic remote = session.getBasicRemote();
remote.setBatchingAllowed(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
remote.sendText(MESSAGE);
}
// Ensure remaining messages are flushed
remote.setBatchingAllowed(false);
}
LSPProcessManager.java 文件源码
项目:cloud-language-servers-container
阅读 25
收藏 0
点赞 0
评论 0
OutputStreamHandler(RemoteEndpoint.Basic remoteEndpointBasic, InputStream out) {
this.remote = remoteEndpointBasic;
this.out = out;
}
MessageSender.java 文件源码
项目:WhiteboardProject
阅读 35
收藏 0
点赞 0
评论 0
public void sendMessage(Message message) throws IOException{
Basic basic= session.getBasicRemote();
basic.sendText(message.getString());
}
MockWebsocketSession.java 文件源码
项目:WhiteboardProject
阅读 34
收藏 0
点赞 0
评论 0
@Override
public Basic getBasicRemote() {
Basic basic= new MockBasic();
return basic;
}
MockMessageSender.java 文件源码
项目:WhiteboardProject
阅读 24
收藏 0
点赞 0
评论 0
public void sendMessage(Message message) throws IOException{
Basic basic= session.getBasicRemote(); // MockWebsocketSession returns a MockBasic
basic.sendText(message.getString()); // MockBasic sendText does nothing
}
WebSocketHelper.java 文件源码
项目:hawkular-commons
阅读 25
收藏 0
点赞 0
评论 0
public void sendTextSync(Session session, String text) throws IOException {
Basic basicRemote = session.getBasicRemote();
basicRemote.sendText(text);
}
FakeSession.java 文件源码
项目:cyberattack-event-collector
阅读 33
收藏 0
点赞 0
评论 0
public Basic getBasicRemote() {
// TODO Auto-generated method stub
return null;
}