在C#WCF中发布/订阅模式

时间:2016-01-19 10:49:25

标签: c# wcf publish-subscribe

如何在服务器上注册客户端以收听一些更改?我希望通知我的客户端并在我的服务器上发生更改时发送一些数据。另外,我使用NetTcpBinding。我尝试了很多例子,但是我无法从服务器获取方法来注册。我没有任何配置文件。

提前致谢。

有在服务器上注册客户端的示例。

{
	"author": "My Name",
	"name": "My App Name",
	"version": "0.0.1",
	"dependencies": {},
	"devDependencies": {
		"chai": "2.2.0",
		"gulp": "3.9.x",
		"gulp-angular-filesort": "1.1.1",
		"gulp-bower-files": "0.1.x",
		"gulp-clean": "0.2.x",
		"gulp-debug": "2.1.x",
		"gulp-concat": "2.2.x",
		"gulp-filter": "1.0.x",
		"gulp-inject": "0.4.x",
		"gulp-less": "1.2.3",
		"gulp-livereload": "1.3.x",
		"gulp-tsc": "0.10.x",
		"gulp-uglify": "1.2.x",
		"gulp-util": "2.2.x",
		"gulp-watch": "0.6.x",
		"karma-coverage": "~0.2.4",
		"karma-mocha": "~0.1.6",
		"karma-phantomjs-launcher": "^0.1.4",
		"karma-sinon-chai": "~0.2.0",
		"merge-stream": "0.1.x",
		"mocha": "~1.20.1",
		"phantomjs": "^1.9.17",
		"q": "1.0.x",
		"run-sequence": "0.3.x"
	}
}

1 个答案:

答案 0 :(得分:0)

您可以在WCF服务中使用CallBack功能,它可用于发送任何实体或对象值的更改。在这种情况下,客户端必须充当服务器和服务器作为客户端,以根据接收更改的客户端中的方法接收更新。 更详细的解释:http://www.dotnetcurry.com/wcf/721/push-data-wcf-callback-service