日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

关于Remoting信道的通信的问题

發布時間:2023/12/31 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关于Remoting信道的通信的问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
關于Remoting信道的通信的問題 我是今年才畢業的應屆生,找了一家公司,主要從事.net開發。公司讓我從事Remoting開發,最近幾天看了wayfarer的一些文章,覺得很好,自己也試著做了一個小程序,不知道為什么達不到預期的效果。
現在把程序發上來,希望大家能為我解決問題。
遠程類:
using?System;
using?System.Runtime.Remoting;

namespace?Distribution_Framework
{
????
//定義廣播事件的參數類
????[Serializable]
????
public?class?BroadcastEventArgs?:?EventArgs
????
{
????????
private?string?msg?=?null;
????????
public?BroadcastEventArgs(string?message)
????????
{
????????????msg?
=?message;
????????}

????????
public?string?Message
????????
{
????????????
get
????????????
{
????????????????
return?msg;
????????????}

????????}

????}

????
public?delegate?void?BroadcastEventHandler(object?sender,?BroadcastEventArgs?submitArgs);
????
public?class?InfoCenter?:?MarshalByRefObject
????
{
????????
private?static?int?count=?0;
????????
public?InfoCenter()
????????
{
????????????count?
=?count+1;
????????????Console.Write(count.ToString());
????????????Console.WriteLine(
"InfoCenter?created.");
????????}

????????
public?override?object?InitializeLifetimeService()
????????
{
????????????
return?null;
????????}

????????
public?event?BroadcastEventHandler?Broadcaster;
????????
public?void?Broadcasting(string?message)
????????
{
????????????BroadcastEventArgs?e?
=?new?BroadcastEventArgs(message);

????????????
if?(Broadcaster?!=?null)
????????????
{
????????????????Broadcaster(
this,?e);//發出事件
????????????????Console.WriteLine("Broadcast:"?+?e.Message);
????????????}

????????}

????}

}





服務端:
using?System;
using?System.Runtime.Remoting;
using?System.Runtime.Remoting.Channels;
using?System.Runtime.Remoting.Channels.Http;
using?System.Runtime.Serialization.Formatters;
using?System.Collections;
//using?System.Runtime.Remoting.Services;
//using?directive;

namespace?Distribution_Framework
{
????
class?Server
????
{
????????
public?static?void?Main(string[]?Args)
????????
{
????????????RemotingConfiguration.Configure(
@"F:\Broadcast\Server\Server\Server.exe.config");?

????????????
/**//*IDictionary?channelProps?=?new?Hashtable();
????????????channelProps["name"]?="BroadCaster";
????????????channelProps["priority"]?=1;
????????????channelProps["port"]=8011;

????????????BinaryServerFormatterSinkProvider?sinkProvider?=?new?BinaryServerFormatterSinkProvider();
????????????sinkProvider.TypeFilterLevel?=TypeFilterLevel.Full;
????????????HttpServerChannel?channel?=?new?HttpServerChannel(channelProps,sinkProvider);
????????????ChannelServices.RegisterChannel(channel);
*/


????????????Console.WriteLine(
"Server?is?running,?Press?Enter?key?to?exit.");
????????????Console.ReadLine();
????????

????????????
/**//*RemotingConfiguration.RegisterWellKnownServiceType(typeof(Distribution_Framework.InfoCenter),?"Broadcast",?WellKnownObjectMode.Singleton);
????????????HttpChannel?myChannel?=?new?HttpChannel(8011);
????????????ChannelServices.RegisterChannel(myChannel);

????????????IServerChannelSink?sc?=?myChannel.ChannelSinkChain;
????????????while?(sc?!=?null)
????????????{
????????????????if?(sc?is?BinaryServerFormatterSink)
????????????????{
????????????????????((BinaryServerFormatterSink)sc).TypeFilterLevel?=?TypeFilterLevel.Full;
????????????????????//break;
????????????????}
????????????????if?(sc?is?SoapServerFormatterSink)
????????????????{
????????????????????((SoapServerFormatterSink)sc).TypeFilterLevel?=?TypeFilterLevel.Full;
????????????????????//break;
????????????????}
????????????????sc?=?sc.NextChannelSink;
????????????}
????????????Console.WriteLine("Server?is?running,?Press?Enter?key?to?exit.");
????????????Console.ReadLine();
????????
*/



????????}

????}

}


Annoncer:
using?System;
using?System.Timers;
using?System.Runtime.Remoting;
using?System.Runtime.Remoting.Channels;
using?System.Runtime.Remoting.Channels.Http;


namespace?Distribution_Framework
{
????
class?Announcer
????
{
????????InfoCenter?infoCenter;

????????
public?static?void?Main(string[]?Args)
????????
{
????????????
/**//*HttpChannel?channel?=?new?HttpChannel();
????????????ChannelServices.RegisterChannel(channel);
????????????RemotingServices.Connect(typeof(InfoCenter),"
http://localhost:8011/BroadCaster");*/

????????????Announcer?announcer?
=?new?Announcer();
????????????announcer.Run();
????????????Console.WriteLine(
"The?announcer?has?been?started.");
????????????Console.ReadLine();
????????}


????????
public?void?Run()
????????
{
????????????
try
????????????
{
????????????????RemotingConfiguration.Configure(
@"F:\Broadcast\Announcer\Announcer\Announcer.exe.config");
????????????????
//infoCenter?=?new?InfoCenter();
????????????????Timer?timer?=?new?Timer(1000);
????????????????timer.Elapsed?
+=?new?System.Timers.ElapsedEventHandler(this.timer_Elapsed);
????????????????timer.Enabled?
=?true;
????????????}

????????????
catch(Exception?ex)
????????????
{
????????????????Console.WriteLine(ex.ToString());
????????????????Console.ReadLine();
????????????}

????????}


????????
private?void?timer_Elapsed(object?sender,?System.Timers.ElapsedEventArgs?e)
????????
{
????????????
string?msg?=?"The?Time?is:?"?+?DateTime.Now.ToString();
????????????Console.WriteLine(
"Send?Message:"?+?msg);
????????????infoCenter.Broadcasting(msg.ToString());
????????}

????}

}


客戶端:
using?System;
using?System.Runtime.Remoting;
using?System.Runtime.Remoting.Channels;
using?System.Runtime.Remoting.Channels.Http;
using?System.Collections;
using?System.Runtime.Serialization.Formatters;

namespace?Distribution_Framework
{
????
class?Receiver?:?MarshalByRefObject
????
{
????????InfoCenter?infoCenter;
????????
public?Receiver()
????????
{
????????}


????????
public?override?object?InitializeLifetimeService()?
????????
{
????????????
return?null;
????????}


????????
public?void?Run()
????????
{
????????????
try
????????????
{
????????????????
//RemotingConfiguration.Configure(@"F:\Broadcast\Receiver\Receiver\Receiver.exe.config");
????????????????HttpChannel?channel?=?new?HttpChannel();
????????????????ChannelServices.RegisterChannel(channel);
????????????????RemotingServices.Connect(
typeof(InfoCenter),"http://localhost:8011/BroadCaseter");
????????????????infoCenter?
=?new?InfoCenter();
????????????????
//訂閱信息
????????????????infoCenter.Broadcaster?+=?new?BroadcastEventHandler(this.BroadcastReceiver);
????????????????
//infoCenter.Broadcasting("hello");
????????????????Console.WriteLine("Ready?to?Recieve?Message");
????????????????Console.ReadLine();
????????????}

????????????
catch(Exception?ex)
????????????
{
????????????????Console.WriteLine(ex.Message);
????????????????Console.ReadLine();
????????????}

????????????
//取消訂閱
????????????
//infoCenter.Broadcaster?-=?new?BroadcastEventHandler(this.BroadcastReceiver);
????????}


????????
public?void?BroadcastReceiver(object?sender,?BroadcastEventArgs?args)
????????
{
????????????Console.WriteLine(
"Received:"?+?args.Message);//打印接收信息
????????}


????????
public?static?void?Main()
????????
{
????????????Receiver?receiver?
=?new?Receiver();
????????????receiver.Run();
????????}

????}

}



在客戶端如果用配置文件就報錯,說<channels>附進有錯誤。
客戶端配置文件:
<?xml?version="1.0"?encoding="utf-8"??>
<configuration>
???
<system.runtime.remoting>
??????
<application>
?????????
<client>
????????????
<client?url="http://localhost:8011/BroadCaster">
????????????????
<activated?type="Distribution_Framework.InfoCenter,?InfoCenter"/>
????????????
</client>
?????????
<channels>
????????????
<channel?ref="http"?port="0"/>
????????????????
<serverProviders>
??????????????????
<provider?ref="binary"?typeFilterLevel="Full"/>
????????????????
</serverProviders>
?????????
</channels>
??????
</application>
???
</system.runtime.remoting>
</configuration>
posted on 2006-04-19 08:34?偷回憶的人 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/liuwenjun830/archive/2006/04/19/378733.html

總結

以上是生活随笔為你收集整理的关于Remoting信道的通信的问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 免费网站在线观看视频 | 特黄特色特刺激免费播放 | 二区三区视频 | 男女一级特黄 | 日本在线免费 | 4444亚洲人成无码网在线观看 | 91麻豆映画传媒 | 国产精品色婷婷99久久精品 | 亚洲三级av | 97碰碰碰 | 精品女同一区 | 国产网站免费在线观看 | 欧美成人a | 尹人久久 | 97超碰网| 夜色成人网 | 日本一区二区精品 | www.成人在线视频 | kendra lust free xxx| 欧美亚洲综合久久 | 国产精品第1页 | 国产第5页 | 免费色网址 | 91丨九色丨丰满人妖 | 国产精品3p视频 | 成人免费毛片入口 | 亚洲国产aⅴ成人精品无吗 日韩乱论 | 综合色婷婷一区二区亚洲欧美国产 | 免费黄色在线播放 | 国产小视频你懂的 | 久久的色偷偷 | 国产在线观看不卡 | 中文字幕黄色片 | 国产一区二区三区四区 | 男人爱看的网站 | 69re视频| 在线视频亚洲欧美 | 西西人体44www大胆无码 | 69社| 国产精品网站视频 | 又色又爽又黄 | 国产精欧美一区二区三区白种人 | 在线综合色 | 亚洲精华液一区二区 | 色哟哟一区二区三区四区 | 日韩精品电影一区 | 日批毛片| 主播av在线 | 人人草人人看 | 久久成人激情 | 三上悠亚一区二区三区 | 免费毛片网 | av中文字幕网 | 国产精品国产三级国产普通话蜜臀 | 亚洲88| 国产精品久久久网站 | 国产suv精品一区二区33 | 欧洲女性下面有没有毛发 | 国产男女无遮挡猛进猛出 | 爱如潮水3免费观看日本高清 | 四房婷婷| 中文字幕第100页 | 国产精品一区在线 | 色婷婷在线播放 | 禁漫天堂免费网站 | 91精品国产综合久久久久久久 | 在线视频国产一区 | 欧美精品www | jzzijzzij亚洲成熟少妇在线播放 狠狠躁日日躁夜夜躁2022麻豆 | 久久先锋| 国产一国产二国产三 | 国内精品少妇 | 高跟鞋av| 精品久久久久一区二区 | 日韩中文一区 | 99re在线| 丰满熟妇被猛烈进入高清片 | 欧美午夜在线 | 国产国语性生话播放 | 91网站在线播放 | 国产中文字幕三区 | 美女三级黄色 | 91成人破解版 | 免费在线色 | 精品久久久久一区二区 | 97少妇| 欧美日韩视频网站 | 日本一级淫片色费放 | 中文字幕亚洲精品在线观看 | 黄色毛毛片 | 日韩专区在线播放 | 超碰成人在线免费观看 | 伊人伊人鲁| 亚洲女同在线 | 成人做爰www免费看视频网站 | 久久人体视频 | 天堂在线资源8 | 久久精品欧美一区 | av色片|