fszmq


Pub-Sub Message Evelopes

Subscriber only wants messages whose topic frame is "B"

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
#r "fszmq.dll"
open fszmq
open System.Text

let s_recv = Socket.recv >> Encoding.ASCII.GetString

let main () =
  // prepare our context and subscriber
  use context     = new Context ()
  use subscriber  = Context.sub context
  Socket.connect subscriber "tcp://localhost:5563"
  Socket.subscribe subscriber [| "B"B |]

  while true do
    // read envelope with address
    let address = s_recv subscriber
    // read message contents
    let contents = s_recv subscriber
    printfn "[%s] %s" address contents

  0 // return code
module docs
module PATH

from docs
val hijack : unit -> unit

Full name: docs.PATH.hijack
namespace fszmq
namespace System
namespace System.Text
val s_recv : (System.IDisposable -> string)

Full name: Psenvsub.s_recv
type Encoding =
  member BodyName : string
  member Clone : unit -> obj
  member CodePage : int
  member DecoderFallback : DecoderFallback with get, set
  member EncoderFallback : EncoderFallback with get, set
  member EncodingName : string
  member Equals : value:obj -> bool
  member GetByteCount : chars:char[] -> int + 3 overloads
  member GetBytes : chars:char[] -> byte[] + 5 overloads
  member GetCharCount : bytes:byte[] -> int + 2 overloads
  ...

Full name: System.Text.Encoding
property Encoding.ASCII: Encoding
Encoding.GetString(bytes: byte []) : string
Encoding.GetString(bytes: byte [], index: int, count: int) : string
val main : unit -> int

Full name: Psenvsub.main
val context : System.IDisposable
val subscriber : System.IDisposable
val address : string
val contents : string
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val release : unit -> unit

Full name: docs.PATH.release
Fork me on GitHub