Uses 569K of libraries. Click here for Pure Java version (1216L/8K/27K).
!752 //1002612 // javax.websocket + implementation (tyrus) !1002664 // JDK 7 tyrus import javax.websocket.*; import org.glassfish.tyrus.client.*; p { S token = loadSecretTextFile("#1002653", "slack-token.txt"); if (token == null) token = devChannelToken(); token = token.trim(); S url = "https://slack.com/api/rtm.start"; Map postData = litmap("token", token, "no_unreads", "1"); S data = doPost(postData, url); Map map = cast jsonDecode(data); //printStructure(map); S websocketURL = getString(map, "url"); print("Websocket URL: " + websocketURL); assertTrue(nempty(websocketURL)); // open websocket //final CountDownLatch messageLatch = new CountDownLatch(1); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); ClientManager client = ClientManager.createClient(); client.connectToServer(new Endpoint() { public void onOpen(Session session, EndpointConfig config) ctex { session.addMessageHandler(new MessageHandler.Whole<String>() { @Override public void onMessage(String message) { System.out.println("Received message: " + message); //messageLatch.countDown(); } }); //session.getBasicRemote().sendText(SENT_MESSAGE); } }, cec, new URI(websocketURL)); //messageLatch.await(100, TimeUnit.SECONDS); }
Began life as a copy of #1002611
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nbgitpuheiab, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002613 |
Snippet name: | Test Slack RTM API 2 (using Tyrus) |
Eternal ID of this version: | #1002613/1 |
Text MD5: | 6b15dc58ca55fca1228dde7033fc5c89 |
Transpilation MD5: | c8bae2754213219287ab7ec09850638f |
Author: | stefan |
Category: | javax / eleu |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-11 00:14:23 |
Source code size: | 1410 bytes / 45 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 722 / 646 |
Referenced in: | [show references] |