Beispiel #1
0
 public bool Publish(string topic, ISocketData sendDto)
 {
     if (string.IsNullOrWhiteSpace(topic))
     {
         throw new ArgumentNullException(topic);
     }
     try
     {
         var sendVal = JsonConvert.SerializeObject(sendDto);
         sendVal = topic + "/" + sendVal;
         var valBytes = Encoding.UTF8.GetBytes(sendVal);
         // var isSend = PublisherSocket.SendMoreFrame(topic).TrySendFrameBytes(sendVal);
         var isSend = PublisherSocket.TrySendFrameBytes(sendVal);
         if (isSend)
         {
             LogWrite.Error("[发布消息]消息已广播出去:" + sendVal);
         }
         return(isSend);
     }
     catch (Exception e)
     {
         LogWrite.Error(e);
         return(false);
     }
 }