コード例 #1
0
ファイル: ChatUserGrain.cs プロジェクト: yymqwl/Barrage
        /*
         *
         * public Task Say(string msg)
         * {
         *   Log.Debug($"SayGrain:ThreadId:{Thread.CurrentThread.ManagedThreadId}");
         *
         *   IMainEntry ime = GrainFactory.GetGrain<IMainEntry>(0);
         *   var chatroom =   ime.GetIChatRoom();
         *
         *
         *   return Task.CompletedTask;
         * }
         */

        public async Task Say(string msg)
        {
            Console.WriteLine(msg);
            IMainEntry ime      = GrainFactory.GetGrain <IMainEntry>(0);
            var        chatroom = await ime.GetIChatRoom();

            await chatroom.BroadCast(new Say_Res
            {
                Msg = $"{this.GetPrimaryKeyLong()}{Name}:{msg}"
            });

            //return Task.CompletedTask;
        }
コード例 #2
0
ファイル: SiloClient.cs プロジェクト: yymqwl/Barrage
        public override bool Init()
        {
            m_ClusterClient = InitialiseClient();

            m_MainEntry = m_ClusterClient.GetGrain <IMainEntry>(0);

            m_SiloGateWay_Obs = new SiloGateWay_Obs();
            m_IGateWay_Obs    = m_ClusterClient.CreateObjectReference <IGateWay_Obs>(m_SiloGateWay_Obs).Result;

            m_IGateWay = m_MainEntry.GetIGateWay().Result;

            m_IGateWay.SubscribeAsync(m_IGateWay_Obs).Wait();

            m_ChatRoom = m_MainEntry.GetIChatRoom().Result;


            return(base.Init());
        }