Name |
Ceylon Network Platform Module |
---|---|
Category |
SDK
The Ceylon SDK |
Backends | JVM |
Maven coordinates | |
Compatible Ceylon release |
JVM: 1.2.x, 1.3.x (latest) |
Published | Mar 11, 2016 |
Stats |
Downloads (JVM): 1154 Source downloads: 850 |
Authors |
Matej Lazar Stéphane Épardaud |
License | Apache Software License |
Description |
This module defines APIs for:
The void getit(String uriAsString) { Uri uri = parse(uriAsString); Request request = uri.get(); Response response = request.execute(); print(response.contents); } A void runServer() { //create a HTTP server value server = newServer { //an endpoint, on the path /hello Endpoint { path = startsWith("/hello"); //handle requests to this path service(Request request, Response response) => response.writeString("hello world"); }, WebSocketEndpoint { path = startsWith("/websocket"); onOpen(WebSocketChannel channel) => print("Channel opened"); onClose(WebSocketChannel channel, CloseReason closeReason) => print("Channel closed"); void onError(WebSocketChannel webSocketChannel, Exception? throwable) {} void onText(WebSocketChannel channel, String text) { print("Received text:"); print(text); channel.sendText(text.uppercased); } void onBinary(WebSocketChannel channel, ByteBuffer binary) { String data = utf8.decode(binary); print("Received binary:"); print(data); value encoded = utf8.encode(data.uppercased); channel.sendBinary(encoded); } } }; //start the server on port 8080 server.start(SocketAddress("127.0.0.1",8080)); } |
Dependencies |
ceylon.collection/1.2.2
shared
ceylon.io/1.2.2
shared
java.base/7 JDK
|
Usage |
import ceylon.net "1.2.2"; |
Module links |
Members Imported By Home Code repository Issue tracker Browse Download .car No .js archive Download source archive Download module documentation View API documentation |