| 1 |
using System; |
| 2 |
using System.Collections; |
| 3 |
using System.Drawing; |
| 4 |
using System.Reactive.Linq; |
| 5 |
using System.Runtime.Remoting.Channels; |
| 6 |
using System.Runtime.Remoting.Channels.Tcp; |
| 7 |
using System.Runtime.Serialization.Formatters; |
| 8 |
using System.Windows.Forms; |
| 9 |
using RxMouseService; |
| 10 |
|
| 11 |
namespace RxMouseClient |
| 12 |
{ |
| 13 |
partial class Program |
| 14 |
{ |
| 15 |
const string SERVICENAME = "MouseService"; |
| 16 |
|
| 17 |
static IObservable<Point> Remoting(string srv, int port) |
| 18 |
{ |
| 19 |
ConfigureRemoting(); |
| 20 |
|
| 21 |
var ms = (IMouseService)Activator.GetObject(typeof(IMouseService), string.Format("tcp://{0}:{1}/{2}", srv, port, SERVICENAME)); |
| 22 |
|
| 23 |
return ms.GetPoints(); |
| 24 |
} |
| 25 |
|
| 26 |
private static void ConfigureRemoting() |
| 27 |
{ |
| 28 |
var server = new BinaryServerFormatterSinkProvider(); |
| 29 |
server.TypeFilterLevel = TypeFilterLevel.Full; |
| 30 |
|
| 31 |
var client = new BinaryClientFormatterSinkProvider(); |
| 32 |
|
| 33 |
IDictionary props = new Hashtable(); |
| 34 |
props["port"] = 0; |
| 35 |
props["name"] = SERVICENAME; |
| 36 |
props["typeFilterLevel"] = TypeFilterLevel.Full; |
| 37 |
|
| 38 |
ChannelServices.RegisterChannel(new TcpChannel(props, client, null), false); |
| 39 |
} |
| 40 |
} |
| 41 |
} |