Bonjour,
je cherche comment faire pour lever un événement sur le serveur auquel serait abonné mon client, cela en Net Remoting.
Je m'explique j'ai mon serveur qui fait des traitements et une fois que cela est terminé, je voudrais avertir mon client que c'est fait. Attention mon client n'a rien fait dans le processus, il est juste la pour faire un affichage.
J'ai un 2° serveur TCP en TcpListener qui recoit des messages de terminaux mobiles sous Compact Framework. C'est à partir d'eux que des traitements sont réalisés.
J'ai trouvé des exemples sur le net mais je n'y pige rien du tout.
Le service est un WellKnowObject singleton.
Voici les bouts de code
Serveur:
le client:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 private static void RunChannelAdmin(){ try { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary prop = new Hashtable(); // prop["bindTo"] = System.Net.Dns.GetHostName();//"192.168.0.12"; prop["port"] = 14000; TcpChannel channel = new TcpChannel(prop, clientProvider, provider); // TcpChannel channel = new TcpChannel(14000); // Enregistrement du canal ChannelServices.RegisterChannel(channel, true); // Démarrage de l'écoute en exposant l'objet en Singleton RemotingConfiguration.RegisterWellKnownServiceType( typeof(ReceptionLivraison.BLL.RemoteBuisnessReception), "RemoteBuisnessReception", WellKnownObjectMode.Singleton); System.Console.WriteLine("Démarré"); FichierLog.Instance.Write("Le serveur d'administration a démarré avec succés"); TimerCallback timerDelegate = new TimerCallback(ecrireCompteur); Timer t = new Timer(timerDelegate,new Compteur(),0,1000); while(true){} } catch { FichierLog.Instance.Write("Erreur lors du démarrage du serveur d'administration"); }finally{ System.Console.WriteLine("Arreter"); } }Quelqu'un pourrait m'aider?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public void StartRemotingClient(Object sender, EventArgs e) { try { if (ChannelServices.RegisteredChannels.Length > 0) ChannelServices.UnregisterChannel(ChannelServices.RegisteredChannels[0]); TcpChannel channel = new TcpChannel(0); ChannelServices.RegisterChannel(channel, true); _RemoteBuisness = (IRemoteBuisnessReception)Activator.GetObject(typeof(IRemoteBuisnessReception), "tcp://" + Parametres.Instance.ListeParam.IPServeur + ":14000/RemoteBuisnessReception"); String GuidServeur = _RemoteBuisness.getServeurGuid(); } catch { throw new RemoteClientException(); } }
Merci d'avance
Partager