This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Connection.cs
97 lines (81 loc) · 2.35 KB
/
Connection.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace LilyBBS.API
{
public class Connection
{
//public bool IsLoggedIn { get; set; }
public static readonly string BbsUrl = "http://bbs.nju.edu.cn/";
public string BaseUrl { get; set; }
public string Cookie { get; set; }
public Connection()
{
Reset();
}
public bool HasSession
{
get
{
return Cookie != null;
}
}
public void Reset()
{
BaseUrl = BbsUrl;
Cookie = null;
}
public void Login(BaseHandler callback, string username, string password)
{
LoginRequest req = new LoginRequest(this, callback);
req.Login(username, password);
}
public void ValidateLogin(BaseHandler callback)
{
ValidateLoginRequest req = new ValidateLoginRequest(this, callback);
req.ValidateLogin();
}
public void SendPost(BaseHandler callback, string brd, string title, string text, int? pid=null, int? gid=null, int signature=1, string autocr="on")
{
SendPostRequest req = new SendPostRequest(this, callback);
req.SendPost(brd, title, text, pid, gid);
}
public void FetchPost(BaseHandler callback, string board, int pid, int num)
{
FetchPostRequest req = new FetchPostRequest(this, callback);
req.FetchPost(board, pid, num);
}
public void FetchTopic(BaseHandler callback, string board, int pid, int? start=null)
{
FetchTopicRequest req = new FetchTopicRequest(this, callback);
req.FetchTopic(board, pid, start);
}
public void FetchPage(BaseHandler callback, string board, int? start=null)
{
FetchPageRequest req = new FetchPageRequest(this, callback);
req.FetchPage(board, start);
}
public void FetchTopTenList(BaseHandler callback)
{
FetchTopTenListRequest req = new FetchTopTenListRequest(this, callback);
req.FetchTopTenList();
}
public void FetchHotList(BaseHandler callback)
{
FetchHotListRequest req = new FetchHotListRequest(this, callback);
req.FetchHotList();
}
#region FetchBoardList
public void FetchBoardList(BaseHandler callback)
{
FetchBoardListRequest req = new FetchBoardListRequest(this, callback);
req.FetchBoardList();
}
private void FetchBoardListCompleted(object sender, BaseEventArgs e)
{
//int i;
}
#endregion
}
}