예제 #1
0
        /// <summary>
        /// Constructor used for outgoing codepaths
        /// </summary>
        /// <param name="client"></param>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <param name="obj"></param>
        private ObjectEntry(SharedObjectsClient client, string name, Guid id, INotifyPropertyChanged obj)
        {
            this.client        = client;
            this.IgnoreChanges = false;

            this.Object = obj;
            this.Id     = id;
            this.Name   = name ?? this.Id.ToString();
            IJsObject jsObj = obj as IJsObject; // do this here so we only do the cast once

            this.IsDynamic = jsObj != null;
            this.Parents   = new Dictionary <Guid, ParentEntry>();
            this.Type      = obj.GetType();

            this.Attributes = new SharedAttributes(obj.GetType());

            if (jsObj != null)
            {
                this.Properties = new SharedPropertyDictionary(jsObj.GetSharedProperties(this.client.ClientId));
            }
            else
            {
                this.Properties = new SharedPropertyDictionary(obj.GetSharedProperties(this.client.ClientId));
            }
        }
예제 #2
0
        public CollectionEntry(SharedObjectsClient client, string name, Type type)
        {
            this.client = client;
            this.Name   = name;
            this.Type   = type;

            this.Items = new Dictionary <Guid, ObjectEntry>();
        }
예제 #3
0
        /// <summary>
        /// Constructor used for Incoming Objects
        /// </summary>
        /// <param name="client"></param>
        public ObjectEntry(SharedObjectsClient client, ObjectPayload payload)
        {
            this.client        = client;
            this.IgnoreChanges = true;

            this.Object     = this.GenerateSharedObject(payload);
            this.Name       = payload.Name;
            this.Id         = payload.Id;
            this.Attributes = payload.Attributes;
            this.IsDynamic  = payload.IsDynamic;
            this.Properties = new SharedPropertyDictionary(payload.SharedProperties);
            this.Parents    = new Dictionary <Guid, ParentEntry>();
            this.Type       = Type.GetType(payload.Type);
        }
예제 #4
0
        /// <summary>
        /// Constructor used for outgoing codepaths
        /// </summary>
        /// <param name="client"></param>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <param name="obj"></param>
        private ObjectEntry(SharedObjectsClient client, string name, Guid id, INotifyPropertyChanged obj)
        {
            this.client = client;
            this.IgnoreChanges = false;
            
            this.Object = obj;
            this.Id = id;
            this.Name = name ?? this.Id.ToString();
            IJsObject jsObj = obj as IJsObject; // do this here so we only do the cast once
            this.IsDynamic = jsObj != null;
            this.Parents = new Dictionary<Guid, ParentEntry>();
            this.Type = obj.GetType();

            this.Attributes = new SharedAttributes(obj.GetType());

            if(jsObj != null)
            {
                this.Properties = new SharedPropertyDictionary(jsObj.GetSharedProperties(this.client.ClientId));
            }
            else
            {
                this.Properties = new SharedPropertyDictionary(obj.GetSharedProperties(this.client.ClientId));
            }
        }
예제 #5
0
        /// <summary>
        /// Constructor used for Incoming Objects
        /// </summary>
        /// <param name="client"></param>
        public ObjectEntry(SharedObjectsClient client, ObjectPayload payload)
        {
            this.client = client;
            this.IgnoreChanges = true;

            this.Object = this.GenerateSharedObject(payload);
            this.Name = payload.Name;
            this.Id = payload.Id;
            this.Attributes = payload.Attributes;
            this.IsDynamic = payload.IsDynamic;
            this.Properties = new SharedPropertyDictionary(payload.SharedProperties);
            this.Parents = new Dictionary<Guid, ParentEntry>();
            this.Type = Type.GetType(payload.Type);
        }
예제 #6
0
 /// <summary>
 /// Constructor used for Outgoing operation of inserting an un-named object into a collection
 /// </summary>
 /// <param name="client"></param>
 /// <param name="obj"></param>
 public ObjectEntry(SharedObjectsClient client, INotifyPropertyChanged obj)
     : this(client, null, Guid.NewGuid(), obj)
 {
     // Un-named objects are set to connected immediately because from the clients perspective they are already live objects
     this.IsConnected = true;
 }
예제 #7
0
 /// <summary>
 /// Constructor used for Outgoing 'Open' requests
 /// </summary>
 /// <param name="client"></param>
 /// <param name="name"></param>
 /// <param name="type"></param>
 public ObjectEntry(SharedObjectsClient client, string name, Type type)
     : this(client, name, Guid.Empty, ConstructSharedType(type))
 {
 }
예제 #8
0
 public ObjectsManager(SharedObjectsClient client)
 {
     this.client = client;
     this.byRef  = new Dictionary <INotifyPropertyChanged, ObjectEntry>();
     this.pendingOpenOperations = new Dictionary <string, OpenOperation>();
 }
예제 #9
0
 /// <summary>
 /// Constructor used for Outgoing operation of inserting an un-named object into a collection
 /// </summary>
 /// <param name="client"></param>
 /// <param name="obj"></param>
 public ObjectEntry(SharedObjectsClient client, INotifyPropertyChanged obj)
     : this(client, null, Guid.NewGuid(), obj)
 {
     // Un-named objects are set to connected immediately because from the clients perspective they are already live objects
     this.IsConnected = true;
 }
예제 #10
0
 /// <summary>
 /// Constructor used for Outgoing 'Open' requests
 /// </summary>
 /// <param name="client"></param>
 /// <param name="name"></param>
 /// <param name="type"></param>
 public ObjectEntry(SharedObjectsClient client, string name, Type type)
     : this(client, name, Guid.Empty, ConstructSharedType(type))
 {
 }
예제 #11
0
 internal SharedInterlocked(SharedObjectsClient client)
 {
     this.Client = client;
 }
예제 #12
0
 public CollectionEntry(SharedObjectsClient client, CollectionOpenedPayload payload)
     : this(client, payload.Name, Type.GetType(payload.Type))
 {
     this.Id = payload.Id;
 }
예제 #13
0
 public OrderedCollectionEntry(SharedObjectsClient client, string name, Type type)
     : base(client, name, type)
 {
     Init();
 }
예제 #14
0
 public OrderedCollectionEntry(SharedObjectsClient client, CollectionOpenedPayload payload)
     : base(client, payload)
 {
     Init();
 }
예제 #15
0
        public CollectionsManager(SharedObjectsClient client)
        {
            this.client = client;

            this.pendingCollections = new Dictionary <string, CollectionEntry>();
        }
예제 #16
0
        public EventLinkPage()
        {
            var text = new Div() { Text = "Server Address:" };
            var textbox = new Input() { Value="elipc:4040" };
            var div = new Div();
            div.Add(text);
            div.Add(textbox);
            Browser.Document.Body.Add(div);

            // Conventional DOM interaction
            var jsonButton = new Button { InnerHtml = "Test JSON..." };
            jsonButton.Click += e =>
            {
                MemoryStream st = new MemoryStream();
                PrincipalObject obj = new PrincipalObject() { Sid = "sa", Id = "eli" };
                Console.WriteLine(obj);

                JsonPayloadWriter w = new JsonPayloadWriter(st);
                var pl = new ObjectPayload(Guid.NewGuid(), obj, Guid.NewGuid(), "ObjectName");
                Console.WriteLine(pl);
                w.Write(string.Empty, pl);
                StreamReader sr = new StreamReader(st);
                string output = sr.ReadToEnd();
                Console.WriteLine(output);
                return;



                //DUMMY TEST
                //string jsont = "{ \"ChannelName\": \"test\" }";
                //JsonPayloadReader jsr = new JsonPayloadReader(jsont);
                //Console.WriteLine(jsr.ReadString("ChannelName"));

                string ns = "namespace1";
                string subscriptionId = "1234";
                Guid clientId = Guid.NewGuid();
                Guid parentId = Guid.NewGuid();
                Guid objectId = Guid.NewGuid();

                Payload payload = new ClientConnectPayload(subscriptionId, clientId, ns, NamespaceLifetime.ServerInstance);
                ETag eTag = new ETag(clientId, 2);
                string json = WriteToJson(payload);
                Console.WriteLine("WROTE: {0}", json);

                JsonPayloadReader jsonReader = new JsonPayloadReader(json);
                var payloadResult = jsonReader.ReadObject<Payload>(string.Empty, Payload.CreateInstance);
                Console.WriteLine("READ OBJECT: {0}", payloadResult);

                EventSet[] events = new EventSet[]
                {
                    new EventSet { Sequence = 0, ChannelName = "test", Payloads = new Payload[] { new ClientConnectPayload(subscriptionId, clientId , ns, NamespaceLifetime.ConnectedOnly) } }
                };

                json = WriteToJson(events);
                Console.WriteLine(json);

                MemoryStream ms = new MemoryStream();
                StreamWriter sw = new StreamWriter(ms);
                sw.Write(json);
                sw.Flush();

                var eventsResult = EventSet.CreateEventSetsFromStream(ms, PayloadFormat.JSON);
                Console.WriteLine(eventsResult);

                var principal = new PrincipalObject() { Id = "Eli", Sid = "sa" };
                var es = new EventSet { Sequence = 0, ChannelName = "test", Payloads = new Payload[] { new ClientConnectPayload(subscriptionId, clientId, ns, NamespaceLifetime.ConnectedOnly, principal) } };

                json = WriteToJson(es);
                Console.Write(json);

                return;              
            };
            Browser.Document.Body.Add(jsonButton);
            
            var soButton = new Button { InnerHtml = "Subscribe Shared Objects Client" };
            soButton.Click += e =>
            {
                var guid = Guid.NewGuid();
                var txt = textbox.Value;

                string path = string.Format("http://{0}/{1}", txt, guid.ToString());

                SharedObjectsClient soc = new SharedObjectsClient(path, NamespaceLifetime.ConnectedOnly);
                PrincipalObject principal = new PrincipalObject() { Id = "ClientA", Sid = "sa" };
                soc.PrincipalObject = principal;
                
                soc.Connect();
                Console.WriteLine("Connecting to:{0}", path);
                soc.Connected += (s, ec) =>
                {
                    Console.WriteLine("CONNECTED TO SHARED OBJECTS SERVER");
                };
            };
            Browser.Document.Body.Add(soButton);

            // Conventional DOM interaction
            var subButton = new Button { InnerHtml = "Subscribe..." };
            subButton.Click += e =>
            {
                Console.WriteLine("Subscribing...");

                Uri uri = new Uri("http://elipc:4040/");
                this.client = new EventLinkClient(uri, "3bb04637-af98-40e9-ad65-64fb2668a0d2", (s, ex) =>
                {
                    Console.WriteLine(string.Format("Error state:{0} exception:{1}", s, ex));
                });
                this.client.Subscribe("99ca2aff-538e-49f2-a71c-79b7720e3f21ClientControl", EventLinkEventsReceived, this.OnSubscriptionInitialized);
                return;

                //this.Channel = new EventLinkChannel(new Uri("http://elipc:4040/"), "nameSpace", (c1, c2) =>
                //{
                //    Write("Error state changed");
                //});

                //this.Channel.SubscriptionInitialized += OnIncomingChannelsInitialized;
                //this.Channel.EventsReceived += OnIncomingChannelsDataReceived;
                //string name = Channels.GetClientName(Guid.NewGuid());
                //this.Channel.SubscribeAsync(name);

                //Uri uri = new Uri("http://elipc:4040/");
                //this.client = new EventLinkClient(uri, "f148dc15-ad26-484e-9f74-8d0655e8fc0d", (s, ex) =>
                //{
                //    Console.WriteLine(string.Format("Error state:{0} exception:{1}", s, ex));
                //});
                //this.client.Subscribe("81dddf4c-f84c-414f-9f04-99f926fc8c68ClientControl", EventLinkEventsReceived, () => this.OnSubscriptionInitialized());
            };
            Browser.Document.Body.Add(subButton);

            // Conventional DOM interaction
            var secButton = new Button { InnerHtml = "Test Security..." };
            secButton.Click += e =>
            {
                Console.WriteLine("sec");

                //var el = new EventLinkClient(new Uri("http://localhost:4040/"), "partitionA", (c) =>
                //{
                //    Write("EventLinkClient Connected");
                //});

                //var att = new SharedAttributes();
                //Write(att);

                //var client = new SharedObjectsClient("http://www.cnn.com/namespaceName");
                //Write(client);

                //client.Connect();

                Guid g = Guid.NewGuid();
                Console.WriteLine(g);

                Guid g2 = Guid.Empty;
                Console.WriteLine(g2);

                ETag e2 = new ETag(Guid.Empty);
                Console.WriteLine(e2);

                SharedObjectSecurity s = new SharedObjectSecurity("Security", false, new ETag(Guid.Empty));
                s.AddAccessRule(new SharedObjectAccessRule("Idenity", ObjectRights.ChangePermissions, System.Security.AccessControl.InheritanceFlags.ContainerInherit, System.Security.AccessControl.AccessControlType.Allow));
                Console.WriteLine(s);

                PrincipalObject p = new PrincipalObject() { Id = "Hello", Sid = "Sid" };
                Console.WriteLine(p);

                SharedEntryMap<SampleEntry> map = new SharedEntryMap<SampleEntry>();
                Console.WriteLine(map);

                var attr = new SharedAttributes();
                Console.WriteLine(attr);

                var ep = new ObjectExpirationPolicy("timespan", TimeSpan.FromDays(1), TimeSpan.FromMilliseconds(100));
                Console.WriteLine(ep);

                var v = new ProtocolVersion(1, 0);
                Console.WriteLine(v);

                //var tp = new TracePayload("Message", Guid.Empty);
                //Write(tp);


                
                //ObjectDeletedPayload p2 = new ObjectDeletedPayload(Guid.Empty, Guid.NewGuid());
                //Write(p2);

                ////WAIT FOR SAHRED PROEPRPT
                ////ClientConnectPayload c = new ClientConnectPayload("sub", Guid.Empty, "namespace");
                ////Write(c);



                //var principalObject = new PrincipalObject() { Id = "Eli", Sid = "sa" };
                ////                var principal = new ObjectPayload(Guid.NewGuid(), principalObject, Guid.NewGuid(), "NamedObject");

                //var sharedProps = new Dictionary<short, SharedProperty>();
                //Write(sharedProps);

                ////TODO THIS IS BROKEN 
                ////var spd = new SharedPropertyDictionary();
                ////Write(spd);
                
                //var puo = new PropertyUpdateOperation();
                //Write(puo);



                //JavascriptHttpStream str = new JavascriptHttpStream(null);
                //BinaryReader br = new BinaryReader(str);
                //BinaryWriter bw = new BinaryWriter(str);
                //BinaryReader br = new BinaryReader(null);
                //BinaryWriter bw = new BinaryWriter(null);

                
                
            };
            //Browser.Document.Body.Add(secButton);

            // Conventional DOM interaction
            var linqButton = new Button { InnerHtml = "Test Linq..." };
            linqButton.Click += e =>
            {
                int value = "abc".Select(a => a - 'a').Sum();
                Console.WriteLine(value);

                value = "abcdefg".Select(a => a - 'a').Sum();
                Console.WriteLine(value);
            };

            //Browser.Document.Body.Add(linqButton);
        }