mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
websocket: move library files to root of module
This commit is contained in:
23
vlib/net/websocket/io.v
Normal file
23
vlib/net/websocket/io.v
Normal file
@ -0,0 +1,23 @@
|
||||
module websocket
|
||||
|
||||
fn C.write() int
|
||||
|
||||
fn (ws mut Client) write_to_server(buf voidptr, len int) int {
|
||||
mut bytes_written := 0
|
||||
ws.write_lock.lock()
|
||||
bytes_written = if ws.is_ssl {
|
||||
C.SSL_write(ws.ssl, buf, len)
|
||||
} else {
|
||||
C.write(ws.socket.sockfd, buf, len)
|
||||
}
|
||||
ws.write_lock.unlock()
|
||||
return bytes_written
|
||||
}
|
||||
|
||||
fn (ws &Client) read_from_server(buffer byteptr, buffer_size int) int {
|
||||
return if ws.is_ssl {
|
||||
C.SSL_read(ws.ssl, buffer, buffer_size)
|
||||
} else {
|
||||
C.read(ws.socket.sockfd, buffer, buffer_size)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user