forked from CloudBreadProject/CloudBread
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Global.asax.cs
103 lines (80 loc) · 3.31 KB
/
Global.asax.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* @file Global.asax.cs
* @brief CloudBread startup task processor. \n
* @author Dae Woo Kim
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage.Queue;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using CloudBread.globals;
using CloudBreadRedis;
namespace CloudBread
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
try
{
/// On start up, CreateIfNotExists CloudBreadLog table on Azure Table Storage
/// On start up, CreateIfNotExists messagestolog table on Azure Queue Service
if (globalVal.StorageConnectionString != "")
{
/// this table is used for CloudBread game log saving
/// Azure Storage connection retry policy
var retryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(2), 10);
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(globalVal.StorageConnectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
tableClient.DefaultRequestOptions.RetryPolicy = retryPolicy;
var cloudTable = tableClient.GetTableReference("CloudBreadLog");
cloudTable.CreateIfNotExists();
cloudTable = tableClient.GetTableReference("CloudBreadErrorLog");
cloudTable.CreateIfNotExists();
/// this queue is used for CloudBread queue method game log saving
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
queueClient.DefaultRequestOptions.RetryPolicy = retryPolicy;
CloudQueue queue = queueClient.GetQueueReference("messagestolog"); /// must be lowercase
queue.CreateIfNotExists();
/// this queue is used for CloudBread queue method game log saving
queue = queueClient.GetQueueReference("cloudbread-batch"); /// must be lowercase
queue.CreateIfNotExists();
}
// Regarding to configuration, check startup fill or not
if (globalVal.CloudBreadFillRedisRankSetOnStartup)
{
// execute redis rank fill task
CBRedis.FillAllRankFromDB();
}
}
catch (System.Exception ex)
{
throw ex;
}
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}