{"id":270940,"date":"2023-05-07T09:00:21","date_gmt":"2023-05-07T01:00:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=270940"},"modified":"2023-04-30T14:42:05","modified_gmt":"2023-04-30T06:42:05","slug":"ktor-web-kotlin","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ktor-web-kotlin.html","title":{"rendered":"\u5f02\u6b65\u6846\u67b6Ktor 2.3 \u53d1\u5e03"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Ktor \u662f\u4e00\u4e2a\u5f02\u6b65\u6846\u67b6\uff0c\u7528\u4e8e\u521b\u5efa\u5fae\u670d\u52a1\u3001Web \u5e94\u7528\u7b49\u3002\u4ece\u5934\u5230\u5c3e\u90fd\u662f\u7528 Kotlin \u7f16\u5199\u7684\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n Ktor 2.3.0 \u8fd1\u65e5\u6b63\u5f0f\u53d1\u5e03\uff0c\u8fd9\u6b21\u66f4\u65b0\u4e3a Ktor \u751f\u6001\u5e26\u6765\u4e86\u8bb8\u591a\u65b0\u529f\u80fd\u548c\u6539\u8fdb\u3002\u4ee5\u4e0b\u90e8\u5206\u7b80\u8981\u4ecb\u7ecd\u4e86\u8be5\u7248\u672c\u7684\u4e3b\u8981\u53d8\u5316\uff1a<\/p>\n \u6838\u5fc3\u6539\u8fdb<\/strong><\/div>\n WebSockets ContentNegotiation \u63d2\u4ef6\u7684\u663e\u8bd5\u7c7b\u578b<\/strong><\/span><\/div>\n WebSocket ContentNegotiation \u63d2\u4ef6\u73b0\u5728\u652f\u6301\u6307\u5b9a\u663e\u5f0f\u7c7b\u578b\uff1a<\/p>\n client.webSocket(\"ws:\/\/localhost:8080\/echo\") {\r\n val originalData: Any = Data(\"hello\")\r\n sendSerialized(originalData, typeInfo())\r\n val received = receiveDeserialized<\/data>(typeInfo<\/data>())\r\n\r\n assertEquals(originalData, received)\r\n}<\/data><\/pre>\n |