Hello World Primus with Swift bridge with Objective-C via ActionHeroJS
Prerequisite
- Client : Primus Objective-C
- Server : ActionHeroJS
- Package Manager : CocoaPod
Clone this repos
$ git clone git@github.com:katopz/primus-objc-swift-helloworld.gitGo to primus-objc-swift-helloworld folder
$ cd primus-objc-swift-helloworldInstall pod (in primus-objc-swift-helloworld folder)
$ pod install*But it seem like pod is not in love with Swift yet so try to copy all folders in Pods folder to Swift project as referrence.
Start ActionHeroJS Server (in ActionHeroJS folder)
$ npm startWatching server up and running and smile :D
> my_actionhero_project@0.0.1 start /Users/katopz/git/actionhero
> actionhero start
info: actionhero >> start
2015-05-19 15:36:11 - notice: *** starting actionhero ***
2015-05-19 15:36:11 - warning: running with fakeredis
2015-05-19 15:36:13 - notice: pid: 10994
2015-05-19 15:36:13 - notice: server ID: 192.168.2.63
2015-05-19 15:36:13 - info: ensuring the existence of the chatRoom: defaultRoom
2015-05-19 15:36:13 - info: ensuring the existence of the chatRoom: anotherRoom
2015-05-19 15:36:13 - notice: starting server: web
2015-05-19 15:36:13 - notice: starting server: websocket
2015-05-19 15:36:15 - notice: environment: development
2015-05-19 15:36:15 - notice: *** Server Started @ 2015-05-19 15:36:15 ***
2015-05-19 15:36:15 - info: actionhero member 192.168.2.63 has joined the clusterOpen http://127.0.0.1:8080/chat.html with Browser, console log will show...
connected!
Open primus-objc-swift-helloworld.xcworkspace with XCode and run then console will show...
2015-05-19 17:23:34.853 primus-objc-swift-helloworld[12767:1889850] [open] - The connection has been established.
2015-05-19 17:23:34.855 primus-objc-swift-helloworld[12767:1889850] [data] - Received data: {
context = api;
welcome = "Hello! Welcome to the actionhero api";
}
2015-05-19 17:23:34.857 primus-objc-swift-helloworld[12767:1889850] [data] - Received data: {
context = response;
data = {
connectedAt = 1432031014837;
fingerprint = "<null>";
id = "30a2046f-11a8-466a-b6da-9ab934590427";
params = {
};
pendingActions = 0;
remoteIP = "127.0.0.1";
remotePort = 54441;
rooms = (
);
totalActions = 0;
};
messageCount = 1;
status = OK;
}
2015-05-19 17:23:34.866 primus-objc-swift-helloworld[12767:1889850] [data] - Received data: {
context = response;
data = 1;
messageCount = 2;
status = OK;
}
2015-05-19 17:23:34.869 primus-objc-swift-helloworld[12767:1889850] [data] - Received data: {
context = response;
messageCount = 3;
status = OK;
}
2015-05-19 17:23:34.871 primus-objc-swift-helloworld[12767:1889850] [data] - Received data: {
context = user;
from = "30a2046f-11a8-466a-b6da-9ab934590427";
message = "HelloWorld from Swift!";
room = defaultRoom;
sentAt = 1432031014867;
}
And at server via terminal will show...
2015-05-19 17:23:34 - info: [server: websocket] new connection to=127.0.0.1Viola! Happy Coding!