Java Code Examples for com.adobe.fre.FREObject#getAsInt()

The following examples show how to use com.adobe.fre.FREObject#getAsInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SslGet.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	try {
		FREObject input1 = passedArgs[0];
		url = input1.getAsString();

		FREObject input2 = passedArgs[1];
		query = input2.getAsString();

		FREObject input3 = passedArgs[2];
		timeout = input3.getAsInt();

		new Thread(this).start();

	} catch (final Exception ex) {
		ex.printStackTrace();
	}

	return null;
}
 
Example 2
Source File: TcpInit.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	this.ctx = ctx;

	try {
		FREObject port1_obj = passedArgs[0];
		int port1 = port1_obj.getAsInt();

		synchronized (listening_ports) {
			listening_ports.add(port1);
		}
		
		new Thread(this).start();

	} catch (final Exception ex) {
		System.err.println(ex);
		ex.printStackTrace();
	}

	return null;
}
 
Example 3
Source File: TcpCloseSocket.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	try {
		FREObject input = passedArgs[0];
		final int socket_id = input.getAsInt();
		tcp_init.closeSocket(socket_id);
	} catch (final Exception ex) {
		ex.printStackTrace();
	}
	return null;
}
 
Example 4
Source File: TcpWriteBytes.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	try {
		FREObject input = passedArgs[0];
		final int socket_id = input.getAsInt();

		final TcpSocket tcp_socket = tcp_init.getTcpSocket(socket_id);
		if (tcp_socket == null) {
			Log.e("TcpWriteBytes:call()", "tcp socket already closed");
			return null;
		}

		final FREByteArray fre_data = (FREByteArray) passedArgs[1];
		fre_data.acquire();
		final int data_length = (int) fre_data.getLength();
		final ByteBuffer data = fre_data.getBytes();
		final byte [] copy = new byte [data_length];
		data.get(copy);
		fre_data.release();

		tcp_socket.writeBytes(copy);
	} catch (final Exception ex) {
		System.err.println(ex);
		ex.printStackTrace();
	}

	return null;
}
 
Example 5
Source File: TcpReadBytes.java    From vpn-over-dns with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FREObject call(FREContext ctx, FREObject passedArgs[]) {
	TcpSocket tcp_socket = null;

	try {
		FREObject input = passedArgs[0];
		final int socket_id = input.getAsInt();

		tcp_socket = tcp_init.getTcpSocket(socket_id);
		if (tcp_socket == null) {
			Log.e("TcpReadBytes:call()", "tcp socket already closed");
			return null;
		}

		final byte [] data = tcp_socket.readBytes();
		FREByteArray fbe = FREByteArray.newByteArray();
		fbe.setProperty("length", FREObject.newObject(data.length));
		fbe.acquire();
		final ByteBuffer byte_buffer = fbe.getBytes();
		byte_buffer.put(data);
		fbe.release();
		return fbe;
	} catch (final Exception ex) {
		ex.printStackTrace();
	}

	return null;
}
 
Example 6
Source File: BaseFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
protected int getIntFromFREObject(FREObject object) {
	try {
		return object.getAsInt();
	}
	catch(Exception e) {
		e.printStackTrace();
		return 0;
	}
}