MCPcopy Create free account
hub / github.com/DNAProject/DNA / BroadcastToSubscribers

Method BroadcastToSubscribers

http/websocket/websocket/server.go:417–446  ·  view source on GitHub ↗
(contractAddrs map[string]bool, sub int, resp map[string]interface{})

Source from the content-addressed store, hash-verified

415 }
416}
417func (self *WsServer) BroadcastToSubscribers(contractAddrs map[string]bool, sub int, resp map[string]interface{}) {
418 // broadcast SubscribeMap
419 self.Lock()
420 defer self.Unlock()
421 data := marshalResp(resp)
422 for sid, v := range self.SubscribeMap {
423 s := self.SessionList.GetSessionById(sid)
424 if s == nil {
425 continue
426 }
427 if sub == WSTOPIC_JSON_BLOCK && v.SubscribeJsonBlock {
428 s.Send(data)
429 } else if sub == WSTOPIC_RAW_BLOCK && v.SubscribeRawBlock {
430 s.Send(data)
431 } else if sub == WSTOPIC_TXHASHS && v.SubscribeBlockTxHashs {
432 s.Send(data)
433 } else if sub == WSTOPIC_EVENT && v.SubscribeEvent {
434 if len(v.ContractsFilter) == 0 {
435 s.Send(data)
436 continue
437 }
438 for _, addr := range v.ContractsFilter {
439 if contractAddrs[addr] {
440 s.Send(data)
441 break
442 }
443 }
444 }
445 }
446}
447
448func (self *WsServer) initTlsListen() (net.Listener, error) {
449

Callers 3

pushEventFunction · 0.80
pushBlockFunction · 0.80
pushBlockTransactionsFunction · 0.80

Calls 3

marshalRespFunction · 0.85
GetSessionByIdMethod · 0.80
SendMethod · 0.65

Tested by

no test coverage detected