From e3c307aa858f8f81d4cb0a5cfe4271cdc5d984be Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期一, 08 二月 2021 10:40:58 +0800 Subject: [PATCH] add remove keys and remove keys exclude --- bhomebus.go | 66 +++++++++++++++++++-------------- 1 files changed, 38 insertions(+), 28 deletions(-) diff --git a/bhomebus.go b/bhomebus.go index 98f334e..1e3aec3 100644 --- a/bhomebus.go +++ b/bhomebus.go @@ -185,6 +185,44 @@ } } +// Removekeys socket +func (s *Socket) Removekeys(keys []int) int { + if libbhomebus == nil || s.socket == nil { + return -1 + } + + ckey := C.create_int_array(C.int(len(keys))) + defer C.release_int_array(ckey) + if ckey == nil { + return -2 + } + + for i, v := range keys { + C.set_1_int(ckey, C.int(i), C.int(v)) + } + + return int(C.wrap_fn_shm_remove_keys(libbhomebus, ckey, C.int(len(keys)))) +} + +// RemoveOtherkeys socket +func (s *Socket) RemoveOtherkeys(keys []int) int { + if libbhomebus == nil || s.socket == nil { + return -1 + } + + ckey := C.create_int_array(C.int(len(keys))) + defer C.release_int_array(ckey) + if ckey == nil { + return -2 + } + + for i, v := range keys { + C.set_1_int(ckey, C.int(i), C.int(v)) + } + + return int(C.wrap_fn_shm_remove_keys_exclude(libbhomebus, ckey, C.int(len(keys)))) +} + // Socket of bhomebus type Socket struct { socket unsafe.Pointer @@ -630,34 +668,6 @@ return -1 } return 0 -} - -// Removekey socket -func (s *Socket) Removekey(key int) int { - if libbhomebus == nil || s.socket == nil { - return -1 - } - - return int(C.wrap_fn_socket_remove_key(libbhomebus, C.int(key))) -} - -// Removekeys socket -func (s *Socket) Removekeys(keys []int) int { - if libbhomebus == nil || s.socket == nil { - return -1 - } - - ckey := C.create_int_array(C.int(len(keys))) - defer C.release_int_array(ckey) - if ckey == nil { - return -2 - } - - for i, v := range keys { - C.set_1_int(ckey, C.int(i), C.int(v)) - } - - return int(C.wrap_fn_socket_remove_keys(libbhomebus, ckey, C.int(len(keys)))) } // ServerSocket tcp -- Gitblit v1.8.0