| 87 | } |
| 88 | |
| 89 | static bool read_reply(acl::websocket& ws) |
| 90 | { |
| 91 | if (!ws.read_frame_head()) { |
| 92 | printf("read_frame_head error %s\r\n", acl::last_serror()); |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | char cbuf[1024]; |
| 97 | unsigned char opcode = ws.get_frame_opcode(); |
| 98 | switch (opcode) { |
| 99 | case acl::FRAME_TEXT: |
| 100 | case acl::FRAME_BINARY: |
| 101 | break; |
| 102 | default: |
| 103 | printf("invalid opcode: 0x%x\r\n", opcode); |
| 104 | return false; |
| 105 | } |
| 106 | |
| 107 | int ret = ws.read_frame_data(cbuf, sizeof(cbuf) - 1); |
| 108 | if (ret <= 0) { |
| 109 | printf("read_frame_data error\r\n"); |
| 110 | return false; |
| 111 | } |
| 112 | cbuf[ret] = 0; |
| 113 | printf("reply from server: %s, len: %d\r\n", cbuf, ret); |
| 114 | |
| 115 | return true; |
| 116 | } |
| 117 | |
| 118 | static bool upload(const char* addr, const char* filepath) |
| 119 | { |
no test coverage detected
searching dependent graphs…