コード例 #1
0
        /// <summary>
        /// GET: WopiFrame
        /// </summary>
        /// <param name="id">File name</param>
        /// <returns>A ViewResult object</returns>
        public ActionResult Index(string id)
        {
            string sourceDoc = id.ToLower();
            string uid       = ConfigurationManager.AppSettings["BrowserUserName"].ToLower();

            string access_token = AccessTokenUtil.WriteToken(AccessTokenUtil.GenerateToken(uid, sourceDoc));

            List <WopiAction> actions   = DiscoveryUtil.GetDiscoveryInfo();
            string            extention = sourceDoc.Split('.')[sourceDoc.Split('.').Length - 1];
            WopiAction        action    = actions.FirstOrDefault(i => i.ext == extention && i.name == "view");
            string            urlSrc    = action.urlsrc;

            urlSrc = string.Format("{0}WOPISrc={1}",
                                   urlSrc.Substring(0, urlSrc.IndexOf('<')),
                                   HttpUtility.UrlEncode(string.Format("http://{0}/wopi/files/{1}",
                                                                       ConfigurationManager.AppSettings["WOPIServerName"],
                                                                       HttpUtility.UrlEncode(sourceDoc))));

            urlSrc = urlSrc.ToLower().Replace(ConfigurationManager.AppSettings["OfficeServerName"].ToLower().Trim(), ConfigurationManager.AppSettings["OfficeServerIP"]);

            urlSrc = string.Format("{0}&access_token={1}", urlSrc, HttpUtility.UrlEncode(access_token));

            ViewData["URL"] = urlSrc;

            return(View());
        }
コード例 #2
0
 public async Task キャンセルテスト()
 {
     await Assert.ThrowsExceptionAsync <TaskCanceledException>(() =>
     {
         return(DiscoveryUtil.GetRoom("TestRoom", 500));
     }, "タイムアウトがあるのでキャンセルされる");
 }
コード例 #3
0
        public async Task ConnectHost(string roomName, CancellationToken token)
        {
            InitConnect(token);
            var room = await DiscoveryUtil.GetRoom(roomName, token);

            SetConnection(await Connection.ConnectToRoom(room, token: m_Cancellation.Token));
        }
コード例 #4
0
        public async Task ルーム取得の簡易関数テスト()
        {
            byte[] data = Random.GenBytes(64);
            using var server = new UdpClient();
            server.Client.Bind(new IPEndPoint(IPAddress.Any, 0));
            var serverIP = server.Client.LocalEndPoint as IPEndPoint;

            using (var service = new DiscoveryService("FastGetRoom", serverIP, data))
            {
                service.Start();
                var room = await DiscoveryUtil.GetRoom("FastGetRoom");

                Assert.AreEqual("FastGetRoom", room.Name, "ルーム名が一致");
                Assert.AreEqual(To(data), To(room.Data), "設定したデータを受け取れる");
            }
        }