• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IO类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.nkzawa.socketio.client.IO的典型用法代码示例。如果您正苦于以下问题:Java IO类的具体用法?Java IO怎么用?Java IO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IO类属于com.github.nkzawa.socketio.client包,在下文中一共展示了IO类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupSocket

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
private void setupSocket(String server, String token) {
    if (server == null) {
        return;
    }
    if (!server.equals(connectedServer) || mSocket == null) {
        teardownSocket();
        try {
            IO.Options opts = new IO.Options();
            opts.forceNew = true;
            opts.query = "token=" + token;
            mSocket = IO.socket(server, opts);
            setupSocketListeners();
            connectedServer = server;
            mSocket.connect();
        } catch (URISyntaxException e) {
            Log.e(TAG, "Error connecting socket.io.", e);
            statusMessage(getString(R.string.server_not_connected));
        }
    }
}
 
开发者ID:timstableford,项目名称:P-BrainAndroid,代码行数:21,代码来源:MainActivity.java


示例2: initSocket

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
private void initSocket() {

        ipAddress = PreferenceManager.getDefaultSharedPreferences(getApplication()).getString(PREF_KEY_IP_ADDRESS, null); // check if a valid IP address is already saved

        // check if the IP address is valid, is so create and connect to the socket
        if( ipAddress != null ){
            try {
                socket = IO.socket("http://"+ ipAddress +":3000"); // ip address : port no
                socket.connect();
            } catch (URISyntaxException e) {
                Log.e(TAG, "initSocket: ", e); // log errors if any
            }
        }else{
            Toast.makeText( getApplicationContext(), "ENTER IP", Toast.LENGTH_SHORT).show(); // display message to user that IP is invalid
        }
    }
 
开发者ID:dhananjaypugalendi,项目名称:SpiderSocket,代码行数:17,代码来源:MainActivity.java


示例3: WebRtcClient

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
public WebRtcClient(RtcListener listener, String host, PeerConnectionClient.PeerConnectionParameters params) {
    mListener = listener;
    pcParams = params;
    PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
            params.videoCodecHwAcceleration);
    factory = new PeerConnectionFactory();
    MessageHandler messageHandler = new MessageHandler();

    try {
        client = IO.socket(host);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    client.on("id", messageHandler.onId);
    client.on("message", messageHandler.onMessage);
    client.connect();

    iceServers.add(new PeerConnection.IceServer("stun:23.21.150.121"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));

    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
    pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
}
 
开发者ID:ardnezar,项目名称:webrtc-android,代码行数:25,代码来源:WebRtcClient.java


示例4: WebRtcClient

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
public WebRtcClient(RtcListener listener, String host, PeerConnectionParameters params, EGLContext mEGLcontext) {
    mListener = listener;
    pcParams = params;
    // initializeAndroidGlobals的第一个参数需要是activity或者application
    PeerConnectionFactory.initializeAndroidGlobals(App.getInstance(), true, true,
            params.videoCodecHwAcceleration, mEGLcontext);
    factory = new PeerConnectionFactory();
    MessageHandler messageHandler = new MessageHandler();

    try {
        client = IO.socket(host);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    client.on("id", messageHandler.onId);
    client.on("message", messageHandler.onMessage);
    client.connect(); // connect后,服务端会emit一个id信息,返回该客户端的id

    iceServers.add(new PeerConnection.IceServer("stun:23.21.150.121"));
    iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));

    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
    pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
}
 
开发者ID:inexistence,项目名称:VideoMeeting,代码行数:26,代码来源:WebRtcClient.java


示例5: setupSocketIO

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
private void setupSocketIO(Server item){
    try {
        io = IO.socket(item.getTargetUrl());

        io.on("log", new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                JSONObject dataReceive = (JSONObject) args[0];

                handleMessage(dataReceive);
            }
        });
    }catch (Exception ex){
        Log.i("Exception", ex.getMessage());
    }
}
 
开发者ID:BlaShadow,项目名称:Remote-Logger-Android,代码行数:17,代码来源:ServerDetails.java


示例6: initClientSocket

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
private void initClientSocket(){
    try {
        //socket = IO.socket("https://cloudchat-xiaominfc.c9.io");
        socket = IO.socket(BASESERVERURL);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    bindBaseEventForSocket();
}
 
开发者ID:xiaominfc,项目名称:pushClientDemo,代码行数:11,代码来源:PushClientService.java


示例7: start

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
public void start()
{
    GlobalCustomName = "";
    GlobalWantsCustomName = false;
    GlobalCustomColor = "";
    GlobalWantsCustomColor = false;
    //try to connect to the server...
    try{
        mSocket = IO.socket("https://palaver-server.herokuapp.com/");
        //mSocket = IO.socket("http://129.21.115.31:3000/");
        Log.d(TAG, "Connected");
    } catch (URISyntaxException e){
        Toast.makeText(this, R.string.connection_error, Toast.LENGTH_SHORT);
        Log.d(TAG, "Error: Unable to connect to IP. " + e.getMessage());
    }
}
 
开发者ID:Sanguinary,项目名称:PalaverAndroidClient,代码行数:17,代码来源:GlobalState.java


示例8: Connect

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
/**
 * Make the connection with the server
 * 
 * @method Connect
 */
public void Connect(){
	
	if(_isConnected){
		return;
	}
	
	try{
       	
		Options opts = new IO.Options();
       	opts.port = 9000;
       	
       	socket = IO.socket("http://192.168.0.2:9000",opts);
       	socket.connect();
       	
       	OffListener();
       	OnConnect();
       	
       } catch (Exception e) {
       	Log.e("SOCKET", "Conextion expection", e);
       }
}
 
开发者ID:cmarrero01,项目名称:socket.io-client.java,代码行数:27,代码来源:Adapter.java


示例9: onCreate

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    try {
        mSocket = IO.socket(Constants.SERVER_IP_ADDRESS);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    initializeSound();
    mediaPlayer.start();
    isReleased = false;
}
 
开发者ID:DeveloperXY,项目名称:TTT,代码行数:15,代码来源:TTTApplication.java


示例10: TrackerServer

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
private TrackerServer(){
    if(mSocket == null){
        try{
            mSocket = IO.socket("http://kalman-tracker-server.herokuapp.com");
        }catch (Exception e){
            e.printStackTrace();
            Log.d("error connecting","to server");
        }
    }
}
 
开发者ID:sebLopezCot,项目名称:6-DOF-Kalman-Tracker,代码行数:11,代码来源:TrackerServer.java


示例11: initSocket

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
@Override
public boolean initSocket() {
    UriBuilder uriBuilder = new UriBuilder();

    try {
          socket = IO.socket(uriBuilder.getSocketUrl().toString());
        return true;
    } catch (URISyntaxException e) {
        SynergykitLog.print(Errors.MSG_SOCKET_INIT_FAILED);
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:SynergyKit,项目名称:synergykit-sdk-android,代码行数:14,代码来源:Socket.java


示例12: SocketClient

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
/**
 *
 * @param address
 * @param port
 * @param callback
 * @throws URISyntaxException
 * @throws MalformedURLException
 */
public SocketClient(String address, Integer port, Long reconnectionTime, Callback callback) throws URISyntaxException, MalformedURLException {
    this.callback = callback;

    URL url = new URL("http", address, port, "");

    IO.Options options = new IO.Options();
    options.forceNew = true;
    options.reconnection = true;
    options.reconnectionDelay = reconnectionTime;

    socket = IO.socket(url.toURI(), options);

    registerEvents();
}
 
开发者ID:rodrigogs,项目名称:mouseless,代码行数:23,代码来源:SocketClient.java


示例13: send

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
/**
 * 回推数据
 * @param handler
 * @param jsonBodyStr
 */
public static synchronized void send(final String handler,final String jsonBodyStr){
	Socket socket = null;
	try {
		LOG.debug("[Websocket Created] Prepared for connect , TIMEOUT="+TIMEOUT+" s,Delay="+DELAY);			
		socket = IO.socket(WSSURL);
		socket.open();
		int times = 0;
		socket.connect();
		//等待连接 超时释放
		while(!socket.connected()&&times*DELAY<=TIMEOUT*1000){
			Thread.sleep(DELAY);
			LOG.debug("[Websocket Connecting] Connecting "+(++times*0.5)+" times");
		}
		if(!socket.connected()){				
			LOG.debug("[Websocket Stop] Lost connection by timeout over "+times*0.5+" s");
			if(socket!=null)socket.close();
		}else{
			socket.emit(handler,jsonBodyStr);
			LOG.debug("[Websocket Success] Sended In "+times*0.5+" s");
		}
	} catch (Exception e1) {
		e1.printStackTrace();
	}finally {
		if(socket!=null)socket.close();
		socket = null;
		LOG.debug("[Websocket Closed] Closed Successfully");
	}
}
 
开发者ID:fier-liu,项目名称:FCat,代码行数:34,代码来源:WssClientUtil.java


示例14: sendURL

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
/**
 * 回推URL
 * @param handler
 * @param data
 */
public static synchronized void sendURL(final String handler,final Map<String,Object> data){
	Socket socket = null;		
	JSONObject jsonObject = new JSONObject();
	try {
		jsonObject.put("data", data);
		LOG.error("[Websocket Created "+handler+"] Prepared for connect , TIMEOUT="+TIMEOUT+" s,Delay="+DELAY);			
		socket = IO.socket(WSSURL);
		socket.open();
		int times = 0;
		socket.connect();
		//等待连接 超时释放
		while(!socket.connected()&&times*DELAY<=TIMEOUT*1000){
			Thread.sleep(DELAY);
			LOG.error("[Websocket Connecting] Connecting "+(++times*0.5)+" times");
		}
		if(!socket.connected()){				
			LOG.error("[Websocket Stop] Lost connection by timeout over "+times*0.5+" s");
		}else{
			socket.emit(handler,JsonUtil.getSuccessJsonObject(jsonObject).toJSONString());
			LOG.error("[Websocket Success] Sended In "+times*0.5+" s");
		}
	} catch (Exception e1) {
		e1.printStackTrace();
	}finally {
		if(socket!=null)socket.close();
		socket = null;
		LOG.error("[Websocket Closed] Closed Successfully");
	}
}
 
开发者ID:fier-liu,项目名称:FCat,代码行数:35,代码来源:WssClientUtil.java


示例15: setUp

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    socket = IO.socket(Constants.SERVER_IP_ADDRESS);
}
 
开发者ID:DeveloperXY,项目名称:TTT,代码行数:5,代码来源:TTTApplicationTest.java


示例16: socket

import com.github.nkzawa.socketio.client.IO; //导入依赖的package包/类
public static Socket socket(final String authToken) throws URISyntaxException {
    IO.Options options = new IO.Options();
    options.forceNew = true;
    options.reconnection = true;
    return socket(authToken, options);
}
 
开发者ID:hugolm84,项目名称:BeaconFinder,代码行数:7,代码来源:SocketIOStatic.java



注:本文中的com.github.nkzawa.socketio.client.IO类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Connector类代码示例发布时间:2022-05-21
下一篇:
Java Slf4jStream类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap