Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/Seta00/zguide into Seta00…

…-master
  • Loading branch information...
commit f0cb91d60cb8b506a7b2229c3d66526fabcd6bfb 2 parents dd7677a + 06c023a
Pieter Hintjens hintjens authored
Showing with 37 additions and 37 deletions.
  1. +37 −37 examples/C#/wuclient.cs
74 examples/C#/wuclient.cs
View
@@ -1,37 +1,37 @@
-//
-// Weather update client
-// Connects SUB socket to tcp://localhost:5556
-// Collects weather updates and finds avg temp in zipcode
-//
-
-// Author: Michael Compton
-// Email: michael.compton@littleedge.co.uk
-
-using System;
-using System.Text;
-using ZMQ;
-
-namespace ZMQGuide {
- class Program {
- static void Main(string[] args) {
- Console.WriteLine("Collecting updates from weather server...");
- // Prepare our context
- using (Context context = new Context(1)) {
- // Socket to talk to server
- using (Socket subscriber = context.Socket(SocketType.PUB)) {
- // Subscribe to zipcode, default is NYC, 10001
- string filter = "10001 ";
- subscriber.Subscribe(filter, Encoding.Unicode);
- int totalTemp = 0;
- int updateNbr = 0;
- for (; updateNbr < 10; updateNbr++) {
- string update = subscriber.Recv(Encoding.Unicode);
- totalTemp += Convert.ToInt32(update.Split()[1]);
- }
- Console.WriteLine("Average temperature for zipcode {0} was {1}F",
- filter, totalTemp / updateNbr);
- }
- }
- }
- }
-}
+//
+// Weather update client
+// Connects SUB socket to tcp://localhost:5556
+// Collects weather updates and finds avg temp in zipcode
+//
+
+// Author: Michael Compton
+// Email: michael.compton@littleedge.co.uk
+
+using System;
+using System.Text;
+using ZMQ;
+
+namespace ZMQGuide {
+ class Program {
+ static void Main(string[] args) {
+ Console.WriteLine("Collecting updates from weather server...");
+ // Prepare our context
+ using (Context context = new Context(1)) {
+ // Socket to talk to server
+ using (Socket subscriber = context.Socket(SocketType.SUB)) {
+ // Subscribe to zipcode, default is NYC, 10001
+ string filter = "10001 ";
+ subscriber.Subscribe(filter, Encoding.Unicode);
+ int totalTemp = 0;
+ int updateNbr = 0;
+ for (; updateNbr < 10; updateNbr++) {
+ string update = subscriber.Recv(Encoding.Unicode);
+ totalTemp += Convert.ToInt32(update.Split()[1]);
+ }
+ Console.WriteLine("Average temperature for zipcode {0} was {1}F",
+ filter, totalTemp / updateNbr);
+ }
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.