On Thursday, May 30, 2013 at 4:16 PM, everton elliott wrote:
Hi,Can any one provide a working example of Sider 0.9 and c# doing publish subscribe?
--
You received this message because you are subscribed to the Google Groups "Sider + Lemonade" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sider-lemonad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Sorry about buzzing on twitter.
I want to write a c# stored procedure to be used with SQLserver 2008r2.
This means can not be .net 4.0.
c:\Csharp>C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe /r:Sider.dll,System.Reactive.Core.dll sider_pubsubtest.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.5420
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
sider_pubsubtest.cs(5,24): error CS0234: The type or namespace name 'Tasks' does not exist in the namespace
'System.Threading' (are you missing an assembly reference?)
Path is set to .net v3.5
Using threading rather than tasks.
Seems that Sider required .net 2 ?
Tried .net 2, can not use 'var' when creating a new object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Sider;
namespace DummyConsole
{
class Program
{
static void Main(string[] args)
{
var pump = new Thread(Pump);
var drain = new Thread(Drain);
pump.Start();
drain.Start();
// Spin for a while waiting for the started thread to become
// alive:
while (!pump.IsAlive);
// wait for pump to end...
pump.Join();
}
private static void Pump()
{
var client = new RedisClient();
while (true) {
client.Publish("HELLO", DateTime.Now.ToString());
Thread.Sleep(1) ;
}
}
private static void Drain()
{
var client = new RedisClient();
var channel = client.Subscribe("HELLO");
channel.Subscribe((m) => Console.WriteLine("SUBSCRIBE BODY ->"+m.Body));
}
}
}
c:\Csharp>csc /r:Sider.dll,System.Reactive.Core.dll sider_pubsubtest.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.5420
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
Sider.dll: warning CS1684: Reference to type 'System.Func`2' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
Sider.dll: warning CS1684: Reference to type 'System.IObservable`1' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
sider_pubsubtest.cs(29,20): error CS1729: 'Sider.RedisClient' does not contain a constructor that takes '0' arguments
Sider.dll: (Location of symbol related to previous error)
sider_pubsubtest.cs(38,20): error CS1729: 'Sider.RedisClient' does not contain a constructor that takes '0' arguments
Sider.dll: (Location of symbol related to previous error)
System.Reactive.Core.dll: warning CS1684: Reference to type 'System.IObservable`1' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
Sider.dll: warning CS1684: Reference to type 'System.Tuple`2' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
Sider.dll: warning CS1684: Reference to type 'System.Tuple`3' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
Sider.dll: warning CS1684: Reference to type 'System.Tuple`4' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
Sider.dll: warning CS1684: Reference to type 'System.Tuple`5' claims it is defined in
'c:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll', but it could not be found
sider_pubsubtest.cs(39,21): error CS0570: 'System.ObservableExtensions.Subscribe<T>()' is not supported by the language
System.Reactive.Core.dll: (Location of symbol related to previous error)
sider_pubsubtest.cs(39,21): error CS0570: 'Subscribe' is not supported by the language
Sider.dll: (Location of symbol related to previous error)
using System;
using System.Collections.Generic;
Trying to write the 'var' to use explicit objects
How do rewrite : IObservable<Message<string> channel = client.Subscribe("HELLO");
private static void Drain()
{
RedisClient<string> client = new RedisClient();
IObservable<Message<string> channel = client.Subscribe("HELLO");
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using Sider;
namespace DummyConsole
{
class Program
{
static void Main(string[] args)
{
Thread pump = new Thread(Pump);
Thread drain = new Thread(Drain);
pump.Start();
drain.Start();
// Spin for a while waiting for the started thread to become
// alive:
while (!pump.IsAlive);
// wait for pump to end...
pump.Join();
}
private static void Pump()
{
RedisClient<string> client = new RedisClient();
while (true) {
client.Publish("HELLO", DateTime.Now.ToString());
Thread.Sleep(1) ;
}
}
private static void Drain()
{
RedisClient<string> client = new RedisClient();
//var channel = client.Subscribe("HELLO");
IObservable<Sider.Message<string>> channel = client.Subscribe("HELLO");
Type types = GetDeclaredType(channel) ;
Console.WriteLine(types.Name) ;
Console.ReadKey();
channel.Subscribe((m) => Console.WriteLine("SUBSCRIBE BODY ->"+m.Body));
}
public static Type GetDeclaredType<T>(T obj)
{
return typeof(T);
}
}
}