本文整理汇总了Java中io.socket.client.IO.Options方法的典型用法代码示例。如果您正苦于以下问题:Java IO.Options方法的具体用法?Java IO.Options怎么用?Java IO.Options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.socket.client.IO
的用法示例。
在下文中一共展示了IO.Options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initNetworking
import io.socket.client.IO; //导入方法依赖的package包/类
GenericOutcome initNetworking() {
if (!networkInitialized) {
String url = "http://" + HOSTNAME + ":" + PORT;
String queryString = PID_KEY + "=" + getProcessID() + "&" +
SDK_VERSION_KEY + "=" + GameLiftServerAPI.SDK_VERSION + "&" +
FLAVOR_KEY + "=" + FLAVOR;
IO.Options options = new IO.Options();
options.query = queryString;
options.reconnection = false;
options.transports = new String[] { "websocket" };
try {
Socket socket = IO.socket(url, options);
sender = new AuxProxyMessageSender(socket);
network = new Network(socket, this);
GenericOutcome result = network.connect();
networkInitialized = result.isSuccessful();
return result;
} catch (URISyntaxException e) {
return new GenericOutcome(new GameLiftError(GameLiftErrorType.LOCAL_CONNECTION_FAILED, e));
}
}
return new GenericOutcome();
}
示例2: socket
import io.socket.client.IO; //导入方法依赖的package包/类
public SailsSocket socket() {
if (url.get() == null) {
throw new RuntimeException("Url must be initialized");
}
IO.Options nOptions = options.get();
if (nOptions == null) {
nOptions = new IO.Options();
}
boolean resetConnection = false;
if (shouldResetNextConnection.get() && sailsSocket != null && !sailsSocket.isConnected()) {
nOptions.forceNew = true;
resetConnection = true;
}
if (sailsSocket == null || resetConnection) {
sailsSocket = new SailsSocket(url.get(), options.get());
shouldResetNextConnection.set(false);
}
return sailsSocket;
}
示例3: testQueryOption
import io.socket.client.IO; //导入方法依赖的package包/类
@Test(timeout = TIMEOUT)
public void testQueryOption() throws Exception {
final BlockingQueue<Object> values = new LinkedBlockingQueue<Object>();
IO.Options options = new IO.Options();
options.query = "x-test-query-one={\"foo\":\"bar\"}";
TestSailsSocketSingleton.getInstance().setUrl(url);
TestSailsSocketSingleton.getInstance().setOptions(options);
SailsSocket sailsSocket = TestSailsSocketSingleton.getInstance().socket();
sailsSocket.get(TAG, "/queryJSON", null, buildResponseListener("get /queryJSON", values));
sailsSocket.connect();
values.take();
sailsSocket.disconnect();
}
示例4: connect
import io.socket.client.IO; //导入方法依赖的package包/类
public void connect(HashMap<String, Emitter.Listener> events) {
mEvents = events;
String url = mServerUrl + "/channel";
IO.Options opts = new IO.Options();
opts.forceNew = true;
opts.query = "A=" + mAppId + "&C=" + mChannelId + "&S=" + mServerName + "&D=" + mDeviceId + "&U=" + xpushSession.getId();
mChannelSocket = null;
try {
mChannelSocket = IO.socket(url, opts);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
if (events != null) {
for (String eventName : events.keySet()) {
this.on(eventName, events.get(eventName));
}
}
mChannelSocket.connect();
}
示例5: startMonitor
import io.socket.client.IO; //导入方法依赖的package包/类
@Override
public void startMonitor() {
if (!isRunning()) {
log.info("Starting RIPE monitor for " + prefix + " / " + host);
IO.Options opts = new IO.Options();
opts.path = "/stream/socket.io/";
try {
this.socket = IO.socket("http://stream-dev.ris.ripe.net/", opts);
this.socket.on(Socket.EVENT_CONNECT, args -> onConnect());
this.socket.on(Socket.EVENT_PONG, args -> socket.emit("ping"));
this.socket.on("ris_message", this::onRisMessage);
} catch (URISyntaxException e) {
log.error("startMonitor()", e);
}
this.socket.connect();
}
}
示例6: Connection
import io.socket.client.IO; //导入方法依赖的package包/类
private Connection() {
if ( USE_PROXY ) {
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
clientBuilder.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXY_SERVER, PROXY_PORT)));
clientBuilder.proxyAuthenticator(new Authenticator() {
@Override
public Request authenticate(Route route, Response response) throws IOException {
String credential = Credentials.basic(PROXY_DOMAIN + "\\" + PROXY_USER, PROXY_PASS);
return response.request().newBuilder().header("Proxy-Authorization", credential).build();
}
});
OkHttpClient client = clientBuilder.build();
IO.setDefaultOkHttpCallFactory(client);
IO.setDefaultOkHttpWebSocketFactory(client);
}
URI prefix = getPrefix();
if ( prefix == null )
return;
IO.Options options = new IO.Options();
options.reconnection = true;
options.reconnectionDelay = 500;
options.reconnectionDelayMax = 60000;
options.transports = new String[]{WEBSOCKET};
connection = IO.socket(prefix, options);
connection.on(Socket.EVENT_CONNECT, this::onConnect);
connection.connect();
}
示例7: getIOOptions
import io.socket.client.IO; //导入方法依赖的package包/类
private IO.Options getIOOptions() {
IO.Options options = new IO.Options();
options.query = "token=" + socketToken;
options.reconnection = true;
options.reconnectionAttempts = 3;
options.reconnectionDelay = 10000;
options.reconnectionDelayMax = 60000;
return options;
}
示例8: initSocket
import io.socket.client.IO; //导入方法依赖的package包/类
private void initSocket() {
try {
if (MainApplication.socket == null) {
IO.Options options = new IO.Options();
options.reconnection = false;
MainApplication.socket = IO.socket(Constants.makeNewIpAddress(MainApplication.ServerHost) + "/msg",options);
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
示例9: AndroidSocket
import io.socket.client.IO; //导入方法依赖的package包/类
public AndroidSocket(IO.Options options, URI uri, HttpImageLoader imageLoader, ImageCacher imageCacher, OnMessageListener onMessageListener) throws NoSuchAlgorithmException, KeyManagementException {
this.options = options;
this.uri = uri;
this.imageLoader = imageLoader;
this.imageCacher = imageCacher;
this.onMessageListener = onMessageListener;
}
示例10: setupSocketClient
import io.socket.client.IO; //导入方法依赖的package包/类
public void setupSocketClient() {
IO.Options options = new IO.Options();
options.query = "username=" +username + "&userid=" + userIdentifier;
try {
socketClient = IO.socket(serverURL, options);
socketClient.connect();
createSocketCommands();
} catch (URISyntaxException e) {
Log.e(TAG, "Fail to create socket: " + e.getMessage());
}
}
示例11: SailsSocket
import io.socket.client.IO; //导入方法依赖的package包/类
public SailsSocket(String url, IO.Options options) {
// Set logger level to FINE
logger.setLevel(Level.FINE);
if (options == null) {
options = new IO.Options();
}
/**
* Solves problem: "Sails v0.11.x is not compatible with the socket.io/sails.io.js
* client SDK version you are using (0.9.0). Please see the v0.11 migration guide
* on http://sailsjs.org for more information".
*
* https://github.com/balderdashy/sails/issues/2640
*/
String sdkVersionQuery = SDK_VERSION_KEY + "=" + SDK_VERSION_VALUE;
if (options.query == null) {
options.query = sdkVersionQuery;
} else {
options.query = options.query + "&" + sdkVersionQuery;
}
try {
socket = IO.socket(url, options);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
requestQueue = new HashSet<SailsSocketRequest>();
Emitter.Listener clearRequestQueue = new Emitter.Listener() {
@Override
public void call(Object... args) {
drainRequestQueue();
}
};
socket.on(Socket.EVENT_CONNECT, clearRequestQueue);
socket.on(Socket.EVENT_RECONNECT, clearRequestQueue);
}
示例12: setOptions
import io.socket.client.IO; //导入方法依赖的package包/类
/**
* @param options initial socket {@link IO.Options}
*/
public void setOptions(IO.Options options) {
if (sailsSocket != null && sailsSocket.isConnected()) {
throw new RuntimeException("Can not change options while socket is connected");
}
if (options != null) this.options.set(options);
}
示例13: shouldNotGetErrorWhenSettingSocketOptions
import io.socket.client.IO; //导入方法依赖的package包/类
@Test(timeout = TIMEOUT)
public void shouldNotGetErrorWhenSettingSocketOptions() throws Exception {
IO.Options options = new IO.Options(){
{
query = "foo=bar";
}
};
TestSailsSocketSingleton.getInstance().setOptions(options);
assertThat(TestSailsSocketSingleton.getInstance().getOptions().query, is("foo=bar"));
}
示例14: SocketManager
import io.socket.client.IO; //导入方法依赖的package包/类
private SocketManager(App app) {
this.app = app;
try {
IO.Options options = new IO.Options();
options.reconnectionAttempts = 0;
socket = IO.socket(BuildVars.BASE_URL, options);
socket.on(Socket.EVENT_CONNECT, onConnect);
socket.on(Socket.EVENT_DISCONNECT, onDisconnect);
socket.on(Socket.EVENT_RECONNECT_ATTEMPT, onReconnectAttempt);
socket.on(Socket.EVENT_RECONNECT, onReconnect);
socket.on(EVENT_AUTHENTICATED, onAuthenticated);
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
示例15: initializeSocket
import io.socket.client.IO; //导入方法依赖的package包/类
private void initializeSocket() {
try{
IO.Options options = new IO.Options();
options.forceNew = true;
mSocket = IO.socket(Constants.CHAT_SERVER_URL,options);
}
catch (Exception e){
Log.e("Error", "Exception in socket creation");
throw new RuntimeException(e);
}
}