{"id":25601428,"url":"https://github.com/magnusthor/xsockets.angularjs.animal.example","last_synced_at":"2026-06-22T22:31:56.533Z","repository":{"id":14544012,"uuid":"17259077","full_name":"MagnusThor/XSockets.AngularJS.Animal.Example","owner":"MagnusThor","description":"XSockets.AngularJS.Animal.Example Simplified  ( refresh )","archived":false,"fork":false,"pushed_at":"2014-05-30T07:06:34.000Z","size":820,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-21T15:55:12.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MagnusThor.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-27T18:19:44.000Z","updated_at":"2014-05-30T07:06:33.000Z","dependencies_parsed_at":"2022-08-02T23:00:25.028Z","dependency_job_id":null,"html_url":"https://github.com/MagnusThor/XSockets.AngularJS.Animal.Example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MagnusThor/XSockets.AngularJS.Animal.Example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2FXSockets.AngularJS.Animal.Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2FXSockets.AngularJS.Animal.Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2FXSockets.AngularJS.Animal.Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2FXSockets.AngularJS.Animal.Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MagnusThor","download_url":"https://codeload.github.com/MagnusThor/XSockets.AngularJS.Animal.Example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2FXSockets.AngularJS.Animal.Example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34668500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-21T15:54:30.552Z","updated_at":"2026-06-22T22:31:56.506Z","avatar_url":"https://github.com/MagnusThor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XSockets.angularJS Provider\n\nThis repo gives you quick introduction how to use the XSockets.NET angularJS (beta) provider.  `['xsockets']`\n\nThe team is currently working on the next major release of XSockets.NET where we will include more streamlined,powerfull and streamlined API's.  Join our developer forum for the latest informaation at http://xsockets.net/developer-forum \n\n###Example usage\n\nYou will find the code in the src folder and try the very simple example at here http://magnusthor.github.io/XSockets.AngularJS.Animal.Example/src\n\n### Reference the provider\n\nInclude the two following JavaScript files\n\n      \u003cscript src=\"/yourscriptfolder/XSockets.latest.js\"\u003e\u003c/script\u003e\n      \u003cscript src=\"/yourscriptfolder/xsockets/XSockets.angularJS.min.js\"\u003e\u003c/script\u003e\n\n\n###Inject the provider \n\n    var myApp = angular.module('animalApp', ['xsockets.angular']);\n\n####Configure the provider\n\nBy invoking the `.setUrl(ws)` method on the $xsocketsProvider for angular you define the endpoint (XSockets.Controller) to be used.\n\n        // Configure the XSockets angularJS provider\n        ..\n        $xsocketsProvider.setUrl(\"ws://joinaspot.com:4509/Generic\");\n        ..\n\n#####Example (Complete example using the `animalApp` as describe above)\n\n    animalApp.config(['$locationProvider', '$routeProvider', 'xsocketsProvider',\n    function ($locationProvider, $routeProvider, $xsocketsProvider) {\n        // Configure the XSockets angularJS provider\n        $xsocketsProvider.setUrl(\"ws://joinaspot.com:4509/Generic\");\n\n        $routeProvider.\n        when('/animals/', {\n            templateUrl: 'app/partials/animals.html',\n            controller: 'AnimalsController'\n        }).\n        when('/dummy/', {\n            templateUrl: 'app/partials/dummy.html',\n            controller: 'DummyController'\n        }).\n        otherwise({\n            redirectTo: '/animals'\n        });\n    }]);\n\n\n####Using the provider in a angularController\n\nWhen the provider is injected and constructed within a controller the provider established a connection to the provided url (.setUrl(ws) .  \n\nExample controller\n\n    animalApp.controller('DummyController', ['$scope', 'xsockets', function ($scope, xsockets) {\n\n    $scope.say = \"Connecting...\";\n\n    // i will only fire once\n    xsockets.onopen.then(function () {\n        $scope.say = \"Connected\";\n    });\n    }]);\n\n###Publish \u0026 Subscribe\n\n####.subscribe(topic,fn) : delegate(fn)\nEstablish a subscription to a topic by invoking `.subscribe(topic,fn).delegate(fn)`\n\n      ...\n       xsockets.subscribe(\"myToic\", function () {\n            console.log(\"Server confirms subscription!\");\n        }).delegate(function (data) {\n            // attach the data to the $scope \n            $scope.myData = data;\n        });\n        ...\n**fn* is an optional argument, if passed the fn will be invoked when the XSockets.Controller confirms that the subscription is established.\n\nPublish data by invoking `.publish(topic,obj,fn)` fn is an optional argument. *fn* will be invoked after the data is sent to the XSockets.Controller\n\n####.publish(topic,data,fn)\n\n    xsockets.publish(\"myTopic\",{say:'Ivory belongs to elephants...'}, function () {\n        console.log(\"You just send some data to the contoller..\");\n    });\n####.one(topic,fn): delegate(fn)\n\n*When using one the API automatically unsubscribes to the topic after a messages arrives.*\n\n    ...\n    xsockets.one(\"myTopic\").delegate(function(data) {\n        // do op's with data\n    });\n    ...\n\n####.many(topic,count,fn): delegate(fn)\n\n*When using many the API automatically unsubscribes to the topic after a specific (count) number of messages arrives)*\n\n    ..\n    xsockets.many(\"myTopic\",5).delegate(function(function(data) {\n        // do op's with data\n    });\n\n####.unsubscribe(topic,fn)\n\nTo remove a subscription, invoke the .unsubscribe method.\n\n    ..\n    xsockets.unsubscribe(\"myTopic\", function(){\n        console.log(\"We are now not subscribing to myTopic\");\n    });\n\n####Events (promises)\n\nThe open, close and error \"events\"  raised by the underlaying XSockets.JavaScript API (WebSocket) are wrapped in a promise/deferred.  Use the .then(success) method to catch the asynchronous callback. \n\n    // Open \u0026 Ready\n    \n    xsockets.onopen.then(function(){\n        // We are now connected and/or ready\n    });\n    \n      // Catch any errors/ exceptions thown\n    \n    xsockets.onerror.then(function(err){\n        // An error occured\n    });\n    \n    xsockets.onclose.then(function(reason){\n        // The connection is closed....\n    });\n    \n    \n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnusthor%2Fxsockets.angularjs.animal.example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagnusthor%2Fxsockets.angularjs.animal.example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnusthor%2Fxsockets.angularjs.animal.example/lists"}