sonyarouje / ddpclient.net Goto Github PK
View Code? Open in Web Editor NEWA DDP client for .NET
A DDP client for .NET
Hi,
If you have your code like this,
DDPClient client = new DDPClient(sub); client.Connect("xxx.xxx.xxx.xxx:3000");
client.Connect will hang if, at the time, the server is down.
Do you know how this situation should be handled?
Thanks
Hey Sony,
we're having some trouble using your package for our App. When we try to tun the sample code, we get the following exception:
[...]
IDataSubscriber subscriber = new Subscriber();
DDPClient client = new DDPClient(subscriber); //<--Exception is thrown here.
client.Connect(our_url);
client.Subscribe(channel);
}
public class Subscriber:IDataSubscriber
{
public void DataReceived(dynamic data)
{
try
{
if (data.type == "sub")
{
//Console.WriteLine(data.prodCode + ": " + data.prodName + ": collection: " + data.collection);
}
}
catch(Exception ex)
{
throw;
}
}
System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
Source=DDPClient.Net
FileName=System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
StackTrace:
at Net.DDP.Client.ResultQueue..ctor(IDataSubscriber subscriber)
at Net.DDP.Client.DDPClient..ctor(IDataSubscriber subscriber)
at YT_Player_Test.MainPage.d__0.MoveNext()
InnerException:
I try a lot to connect with meteor apps using this package. But there is no way to understand what about the connection is work or not. Even no error, no message. following my code:
[class MainClass
{
public static void Main(string[] args)
{
IDataSubscriber subscriber = new Subscriber();
DDPClient client = new DDPClient(subscriber);
client.Connect("localhost:3000");
// or if you want to connect over SSL
// client.Connect("localhost:3000", true);
// or if you prefer a more explicit approach
// client.Connect("localhost:3000", useSsl: true);
client.Subscribe("findproducts");
}
class Subscriber : IDataSubscriber
{
string IDataSubscriber.Session
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void DataReceived(dynamic data)
{
Console.WriteLine(data);
if (data.type == "subs")
{
Console.WriteLine(data.prodCode + ": " + data.prodName + ": collection: " + data.collection);
}
}
//void IDataSubscriber.DataReceived(dynamic data)
//{
// Console.WriteLine(data);
// throw new NotImplementedException();
//}
}](url)
I realy upset after spending couple of hours. :( ++
hi there,
i new in .net c#, i try to call method from meteor sever though ddp.
i using nuget version DDPClient (https://www.nuget.org/packages/Meteor.DDP/), and my visual studio version is 2012.
below is my code that copy from the homepage, but the error show 'meteorddp.Program.Subscriber' does not implement interface member 'Net.DDP.Client.IDataSubscriber.Session'
`using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Net.DDP.Client;
namespace meteorddp
{
class Program
{
static void Main(string[] args)
{
IDataSubscriber subscriber = new Subscriber();
DDPClient client = new DDPClient(subscriber);
client.Connect("localhost:3000");
client.Subscribe("allproducts");
}
public class Subscriber : IDataSubscriber
{
public void DataReceived(dynamic data)
{
try
{
if (data.type == "sub")
{
Console.WriteLine(data.prodCode + ": " + data.prodName + ": collection: " + data.collection);
}
}
catch (Exception ex)
{
throw;
}
}
}
}
}`
so what is the problem cause the error?
thanks
I have no idea what is going on here... I am calling a method via DDPClient once every second and it seems to work fine for about 60 seconds then the server simply stops receiving any messages. No errors anywhere.
if (!WebSocketState.Open.Equals(_mDdpClient1.State)) return;
_mDdpClient1.Call("myServerMethod", MyArg1, MyArg2);
One thing I noticed since the latest version is my IDataSubscriber.DataReceived callback is never being called, where previously it used to get the result of each method call.
I tried rolling back to WebSocket4Net v 0.8 however at runtime I get the following error. Have tried everything but can't seem to find a reference to fix. Deleted all WebSocket4Net.dll and Net.DDP.Client.dll from my PC but somehow Visual Studio keeps looking for the wrong version:
System.IO.FileLoadException was unhandled
HResult=-2146234304
Message=Could not load file or assembly 'WebSocket4Net, Version=0.12.0.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Net.DDP.Client
FileName=WebSocket4Net, Version=0.12.0.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a
FusionLog=""
StackTrace:
at Net.DDP.Client.DDPConnector.Connect(String url, Boolean keepAlive)
at Net.DDP.Client.DDPClient.Connect(String url) in c:\Users\greg\Documents\git\third-party\DDPClient.NET\Net.DDP.Client\DDPClient.cs:line 31
at SerialControlCenter.PCP_simulator.PcpSimulator..ctor(MainForm mf) in c:\Users\greg\Documents\git\internal\SerialControlCenter\SerialControlCenter\PCP_simulator\PCP_simulator.cs:line 163
at SerialControlCenter.MainForm.toolStripAppType_SelectedIndexChanged(Object sender, EventArgs e) in c:\Users\greg\Documents\git\internal\SerialControlCenter\SerialControlCenter\MainForm.cs:line 1020
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ToolStripComboBox.HandleSelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at SerialControlCenter.Program.Main() in c:\Users\greg\Documents\git\internal\SerialControlCenter\SerialControlCenter\Program.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.FileLoadException
HResult=-2146234304
Message=Could not load file or assembly 'WebSocket4Net, Version=0.8.0.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
FileName=WebSocket4Net, Version=0.8.0.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a
FusionLog=Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\greg\Documents\git\internal\SerialControlCenter\SerialControlCenter\bin\Debug\SerialControlCenter.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = WebSocket4Net, Version=0.8.0.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a
(Fully-specified)
LOG: Appbase = file:///C:/Users/greg/Documents/git/internal/SerialControlCenter/SerialControlCenter/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Net.DDP.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\greg\Documents\git\internal\SerialControlCenter\SerialControlCenter\bin\Debug\SerialControlCenter.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 0.8.0.0 redirected to 0.12.0.0.
LOG: Post-policy reference: WebSocket4Net, Version=0.12.0.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a
LOG: Attempting download of new URL file:///C:/Users/greg/Documents/git/internal/SerialControlCenter/SerialControlCenter/bin/Debug/WebSocket4Net.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Recently, Meteor has added authentication. It seems that aside from the traditional username/password authentication, there is also support for Facebook, Twitter and other forms of authentication method. Do you have any plans on adding support for auth? That all aside, this is a wonderful project! Thanks!
JsonDeserializeHelper seems to only handle 3 message types "set", "unset" and "result".
The "result" message seems to work okay, but with Meteor 1.1.0.2 our .NET client is never seeing any "set" or "unset" messages, so data subscription is not working at all.
JsonDeserializeHelper should be updated to support all current DDP messages that can be expected to be received by a Client.
DDP specification can be found here: https://github.com/meteor/meteor/blob/devel/packages/ddp/DDP.md
Clean checkout had build errors. Could not find Newtonsoft.Json.
To fix I had to open NuGet package manager and tick Json.Net for the project Net.DDP.Client
I am running Visual Studio 2013.
what function about client.AddItem()? I do not understand how to use this function.
I have started the following application,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Net.DDP.Client;
namespace Net.DDP.Client.Cli
{
class Program
{
static void Main(string[] args)
{
IDataSubscriber subscriber = new Subscriber();
DDPClient client = new DDPClient(subscriber);
client.Connect("localhost:3000");
client.Subscribe("allMovies");
}
}
public class Subscriber : IDataSubscriber
{
public void DataReceived(dynamic data)
{
try
{
if (data.type == "sub")
{
Console.WriteLine(data.title + ": " + data.director);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Everytime I start the debug, it seems that the command prompt doesn't have any output even though my publish in meteor has some data.
On the Server.js i have this file:
// Declare server Movies collection
Movies = new Meteor.Collection("movies");
// Seed the movie database with a few movies
Meteor.startup(function () {
if (Movies.find().count() == 0) {
Movies.insert({ title: "Star Wars", director: "Lucas" });
Movies.insert({ title: "Memento", director: "Nolan" });
Movies.insert({ title: "King Kong", director: "Jackson" });
}
});
Meteor.publish("allMovies", function () {
return Movies.find(); // everything
});
Any recommendations?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.