当前位置: 首页>>代码示例>>Java>>正文


Java StreamConnectionNotifier类代码示例

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


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

示例1: PAKBluetoothPairingHandler

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
public PAKBluetoothPairingHandler(String password, String eMail,
		String firstName, String lastName, String deviceName,
		X509Certificate ownerCertEnc, X509Certificate ownerCertSign,
		Map<String, X509Certificate> knownDevices,
		Collection<VCard> knownContacts) throws IOException {
	super(PairingType.SLAVE, password, eMail, firstName, lastName,
			deviceName, ownerCertEnc, ownerCertSign, knownDevices,
			knownContacts);
	UUID uuid = new UUID(0x1101); // TODO: Create new unique UUID
	String connectionString = "btspp://localhost:" + uuid
			+ ";name=PanboxImportListener;encrypt=false;authenticate=false";
	streamConnNotifier = (StreamConnectionNotifier) Connector.open(
			connectionString, Connector.READ_WRITE);
	ServiceRecord record = LocalDevice.getLocalDevice().getRecord(
			streamConnNotifier);
	logger.debug("PAKBluetoothPairingHandler : connection is up at: "
			+ record.getConnectionURL(0, false));
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:19,代码来源:PAKBluetoothPairingHandler.java

示例2: run

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
public void run() {
    try {
        StreamConnectionNotifier server = (StreamConnectionNotifier) Connector.open("socket://:" + port);

        Client currentClient = null;

        while (true) {
            StreamConnection connection = server.acceptAndOpen();
            System.out.println("Client Connected.");

            if (currentClient != null) {
                currentClient.kill();
            }

            currentClient = new Client(connection);
            currentClient.start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:runnymederobotics,项目名称:robot2014,代码行数:22,代码来源:RobotServer.java

示例3: startServer

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
/**
 * Opens a server connection ({@link StreamConnectionNotifier}) and starts
 * up {@link IncomingClientListener} if succeeded. If opening of the
 * connection failed, the application will be exited.
 */
public void startServer() {
	System.out.println();
	System.out.println();
	System.out.println("Device:");
	System.out.println("\t" + device.getFriendlyName());
	System.out.println("\t" + device.getBluetoothAddress());
	System.out.println();
	System.out.println();
	try {
		System.out.println("Opening up server connection...");
		server = (StreamConnectionNotifier) Connector.open(URL);
	} catch (IOException e) {
		System.out.println("Failed open server connection: " + e.getMessage());
		System.exit(1);
	}
	System.out.println("Server up and running!");
	IncomingClientListener listener = new IncomingClientListener(server);
	listener.start();
	setAllowClientInput(true);

}
 
开发者ID:golvmopp,项目名称:BGSEP,代码行数:27,代码来源:BluetoothServer.java

示例4: tryToClose

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
private void tryToClose(@Nullable StreamConnectionNotifier ss) {
	try {
		if (ss != null) ss.close();
	} catch (IOException e) {
		if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
	} finally {
		callback.transportDisabled();
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:10,代码来源:BluetoothPlugin.java

示例5: acceptContactConnections

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
private void acceptContactConnections(StreamConnectionNotifier ss) {
	while (true) {
		StreamConnection s;
		try {
			s = ss.acceptAndOpen();
		} catch (IOException e) {
			// This is expected when the socket is closed
			if (LOG.isLoggable(INFO)) LOG.info(e.toString());
			return;
		}
		backoff.reset();
		callback.incomingConnectionCreated(wrapSocket(s));
		if (!running) return;
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:16,代码来源:BluetoothPlugin.java

示例6: bluetoothServer

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
/**
 * start server creating an UUID and a connection String,
 * then waiting for a device to connect
 */
private void bluetoothServer() {
    if (sendReciveMessageThread.isAlive()) {
        sendReciveMessageThread.interrupt();
    }
    try {
        //Create a UUID for SPP
        UUID uuid = new UUID("1101", true);
        //Create the servicve url
        String connectionString = "btspp://localhost:" + uuid + ";name=Sample SPP Server";

        //open server url
        streamConnNotifier = (StreamConnectionNotifier) Connector.open(connectionString);

        //Wait for client connection
        System.out.println("\nServer Started. Waiting for clients to connect...");

        StreamConnection connection = streamConnNotifier.acceptAndOpen();

        System.out.println("Remote device address: " + RemoteDevice.getRemoteDevice(connection).getBluetoothAddress());
        System.out.println("Remote device name: " + RemoteDevice.getRemoteDevice(connection).getFriendlyName(true));

        //the stream is opened both in and out
        outStream = connection.openOutputStream();
        inStream = connection.openInputStream();
        connectionIsAvaible = true;
        SingletonStaticGeneralStats.getInstance().setBluetoothServerCreated(true);
        sendBluetoothMessage();
    } catch (IOException e) {
        e.printStackTrace();
        //in case of problems, the connection is stopped
        closeConnection();
    }
}
 
开发者ID:andrea9293,项目名称:pcstatus,代码行数:38,代码来源:BluetoothSPPServer.java

示例7: getStreamConnection

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
public javax.microedition.io.StreamConnection getStreamConnection(
		javax.microedition.io.Connection connection) throws IOException {
	if (connection instanceof StreamConnectionNotifier) {
		return ((StreamConnectionNotifier) connection).acceptAndOpen();
	} else if (connection instanceof StreamConnection) {
		return (javax.microedition.io.StreamConnection) connection;
	} else {
		throw new IllegalStateException("Connection class not known. "
				+ connection.getClass().getName());
	}
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:12,代码来源:BluetoothLinkFactory.java

示例8: startserver

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
public void startserver() {
    try {
        String url = "btspp://localhost:" + uuid +
                //  new UUID( 0x1101 ).toString() +
                ";name=File Server";
        StreamConnectionNotifier service = (StreamConnectionNotifier) Connector.open(url);

        StreamConnection con = service.acceptAndOpen();
        OutputStream dos = con.openOutputStream();
        InputStream dis = con.openInputStream();

        InputStreamReader daf = new InputStreamReader(System.in);
        BufferedReader sd = new BufferedReader(daf);
        RemoteDevice dev = RemoteDevice.getRemoteDevice(con);

        String greeting = "hi";
        dos.write(greeting.getBytes(Charset.forName("utf-8")));
        dos.flush();
        byte buffer[] = new byte[1024];
        int bytes_read = dis.read(buffer);
        String received = new String(buffer, 0, bytes_read, Charset.forName("utf-8"));
        System.out.println
                ("Message:" + received + "From:"
                        + dev.getBluetoothAddress());
        // con.close();
    } catch (IOException e) {
        System.err.print(e.toString());
    }
}
 
开发者ID:Blaubot,项目名称:Blaubot,代码行数:30,代码来源:rfcommserver.java

示例9: tryToClose

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
private void tryToClose(StreamConnectionNotifier ss) {
	try {
		if(ss != null) ss.close();
	} catch(IOException e) {
		if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
	}
}
 
开发者ID:kiggundu,项目名称:briar,代码行数:8,代码来源:BluetoothPlugin.java

示例10: acceptContactConnections

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
private void acceptContactConnections(StreamConnectionNotifier ss) {
	while(true) {
		StreamConnection s;
		try {
			s = ss.acceptAndOpen();
		} catch(IOException e) {
			// This is expected when the socket is closed
			if(LOG.isLoggable(INFO)) LOG.info(e.toString());
			return;
		}
		callback.incomingConnectionCreated(wrapSocket(s));
		if(!running) return;
	}
}
 
开发者ID:kiggundu,项目名称:briar,代码行数:15,代码来源:BluetoothPlugin.java

示例11: OBEXSessionNotifierImpl

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
/**
 * Applications should not used this function.
 * 
 * @exception Error
 *                if called from outside of BlueCove internal code.
 */
public OBEXSessionNotifierImpl(StreamConnectionNotifier notifier, OBEXConnectionParams obexConnectionParams)
		throws IOException, Error {
	Utils.isLegalAPICall(fqcnSet);
	this.notifier = notifier;
	this.obexConnectionParams = obexConnectionParams;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:13,代码来源:OBEXSessionNotifierImpl.java

示例12: close

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
public void close() throws IOException {
	StreamConnectionNotifier n = this.notifier;
	this.notifier = null;
	if (n != null) {
		n.close();
	}
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:8,代码来源:OBEXSessionNotifierImpl.java

示例13: run

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
public boolean run(String name) {
	try {
		StreamConnectionNotifier server = (StreamConnectionNotifier) Connector
				.open("btspp://localhost:"
						+ uuid
						+ ";name="
						+ name
						+ ";authorize=false;authenticate=false;encrypt=false");

		System.out.println("Server started " + name);
		
		StreamConnection conn = server.acceptAndOpen();

		System.out.println("Server received connection");
		
		DataInputStream dis = new DataInputStream(conn.openInputStream());

		System.out.print("Got message[");
		System.out.print(dis.readUTF());
		System.out.println("]");
		
		dis.close();

		conn.close();

		server.close();
		return true;
	} catch (IOException e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:33,代码来源:SimpleServer.java

示例14: ListeningTask

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
private ListeningTask(StreamConnectionNotifier serverSocket) {
	this.serverSocket = serverSocket;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:4,代码来源:BluetoothPlugin.java

示例15: BluetoothKeyAgreementListener

import javax.microedition.io.StreamConnectionNotifier; //导入依赖的package包/类
private BluetoothKeyAgreementListener(BdfList descriptor,
		StreamConnectionNotifier ss) {
	super(descriptor);
	this.ss = ss;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:6,代码来源:BluetoothPlugin.java


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