fix to carry environment variables
This commit is contained in:
@@ -6,6 +6,8 @@ import org.junit.Before;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
public abstract class Connection {
|
public abstract class Connection {
|
||||||
@@ -78,6 +80,15 @@ public abstract class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String[] createEnv() {
|
String[] createEnv() {
|
||||||
return new String[] {"DEBUG=engine*", "PORT=" + PORT};
|
Map<String, String> env = new HashMap<String, String>(System.getenv());
|
||||||
|
env.put("DEBUG", "engine*");
|
||||||
|
env.put("PORT", String.valueOf(PORT));
|
||||||
|
String[] _env = new String[env.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (String key : env.keySet()) {
|
||||||
|
_env[i] = key + "=" + env.get(key);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return _env;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import com.github.nkzawa.emitter.Emitter;
|
|||||||
import com.github.nkzawa.engineio.client.Socket;
|
import com.github.nkzawa.engineio.client.Socket;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Connection {
|
public class Connection {
|
||||||
|
|
||||||
public static void main(String[] args) throws URISyntaxException {
|
public static void main(String[] args) throws URISyntaxException {
|
||||||
Map<String, String> env = System.getenv();
|
final Socket socket = new Socket("http://localhost:" + System.getenv("PORT"));
|
||||||
final Socket socket = new Socket("http://localhost:" + env.get("PORT"));
|
|
||||||
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
|
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import com.github.nkzawa.emitter.Emitter;
|
|||||||
import com.github.nkzawa.engineio.client.Socket;
|
import com.github.nkzawa.engineio.client.Socket;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ConnectionFailure {
|
public class ConnectionFailure {
|
||||||
|
|
||||||
public static void main(String[] args) throws URISyntaxException {
|
public static void main(String[] args) throws URISyntaxException {
|
||||||
Map<String, String> env = System.getenv();
|
int port = Integer.parseInt(System.getenv("PORT"));
|
||||||
int port = Integer.parseInt(env.get("PORT"));
|
|
||||||
port++;
|
port++;
|
||||||
final Socket socket = new Socket("http://localhost:" + port);
|
final Socket socket = new Socket("http://localhost:" + port);
|
||||||
socket.on(Socket.EVENT_CLOSE, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CLOSE, new Emitter.Listener() {
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import com.github.nkzawa.emitter.Emitter;
|
|||||||
import com.github.nkzawa.engineio.client.Socket;
|
import com.github.nkzawa.engineio.client.Socket;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ImmediateClose {
|
public class ImmediateClose {
|
||||||
|
|
||||||
public static void main(String[] args) throws URISyntaxException {
|
public static void main(String[] args) throws URISyntaxException {
|
||||||
Map<String, String> env = System.getenv();
|
final Socket socket = new Socket("http://localhost:" + System.getenv("PORT"));
|
||||||
final Socket socket = new Socket("http://localhost:" + env.get("PORT"));
|
|
||||||
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
|
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user