-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
マルチ転送フィルターを設定可能にする #62
Changes from 4 commits
da028f5
e2c73d8
3bd9be8
c593ce5
8521ea0
1c5cdd8
91b1e92
45b09ef
53e1d6e
f12b9e0
b98f63f
8d09916
a181a49
ffd5c58
c0ac41c
a670136
d0394af
7ebc714
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,12 +127,51 @@ public class RuleList | |
[Header("ForwardingFilter の設定")] | ||
public bool enableForwardingFilterAction = false; | ||
public string forwardingFilterAction; | ||
public bool enableForwardingFilterName = false; | ||
public string forwardingFilterName; | ||
public bool enableForwardingFilterPriority = false; | ||
public int forwardingFilterPriority; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 全体的に ForwardingFilters の設定と共通化して下さい There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ForwardingFilter の設定と共通化しました。8521ea0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. このあたりの設定も共通のクラスにできるはずです |
||
public RuleList[] forwardingFilter; | ||
public bool enableForwardingFilterVersion = false; | ||
public string forwardingFilterVersion = ""; | ||
public bool enableForwardingFilterMetadata = false; | ||
public string forwardingFilterMetadataMessage = ""; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. マルチ転送フィルター用に新しく項目を追加しました |
||
[System.Serializable] | ||
public class ForwardingFiltersRule | ||
{ | ||
public string field; | ||
public string op; | ||
public string[] values; | ||
} | ||
[System.Serializable] | ||
public class ForwardingFiltersRuleList | ||
{ | ||
public ForwardingFiltersRule[] data; | ||
} | ||
|
||
[System.Serializable] | ||
public class ForwardingFiltersItem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
public string action; | ||
public string name; | ||
public int priority; | ||
public ForwardingFiltersRuleList[] rules; | ||
public string version; | ||
public string metadata; | ||
} | ||
|
||
[System.Serializable] | ||
public class ForwardingFiltersList | ||
{ | ||
public ForwardingFiltersItem[] filters; | ||
} | ||
|
||
[Header("ForwardingFilters の設定")] | ||
|
||
public ForwardingFiltersList forwardingFilters; | ||
|
||
[Header("DataChannel シグナリングの設定")] | ||
public bool dataChannelSignaling = false; | ||
public int dataChannelSignalingTimeout = 30; | ||
|
@@ -777,10 +816,12 @@ public void OnClickStart() | |
} | ||
fixedDataChannelLabels = config.DataChannels.Select(x => x.Label).ToArray(); | ||
} | ||
if (forwardingFilter.Length != 0) | ||
if (forwardingFilter != null && forwardingFilter.Length != 0) | ||
{ | ||
config.ForwardingFilter = new Sora.ForwardingFilter(); | ||
if (enableForwardingFilterAction) config.ForwardingFilter.Action = forwardingFilterAction; | ||
if (enableForwardingFilterName) config.ForwardingFilter.Name = forwardingFilterName; | ||
if (enableForwardingFilterPriority) config.ForwardingFilter.Priority = forwardingFilterPriority; | ||
foreach (var rs in forwardingFilter) | ||
{ | ||
var ccrs = new List<Sora.ForwardingFilter.Rule>(); | ||
|
@@ -789,6 +830,7 @@ public void OnClickStart() | |
var ccr = new Sora.ForwardingFilter.Rule(); | ||
ccr.Field = r.field; | ||
ccr.Operator = r.op; | ||
ccr.Values = new List<string>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
foreach (var v in r.values) | ||
{ | ||
ccr.Values.Add(v); | ||
|
@@ -800,7 +842,79 @@ public void OnClickStart() | |
if (enableForwardingFilterVersion) config.ForwardingFilter.Version = forwardingFilterVersion; | ||
if (enableForwardingFilterMetadata) config.ForwardingFilter.Metadata = forwardingFilterMetadataJson; | ||
} | ||
if (forwardingFilters != null && | ||
forwardingFilters.filters != null && | ||
forwardingFilters.filters.Length > 0) | ||
{ | ||
config.ForwardingFilters = new List<Sora.ForwardingFilter>(); | ||
|
||
foreach (var filter in forwardingFilters.filters) | ||
{ | ||
var newFilter = new Sora.ForwardingFilter(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 共通のクラスにすればこのあたりの処理は forwardingFilter に対する処理と共通化できるはず |
||
|
||
if (!string.IsNullOrEmpty(filter.action)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 通常の転送フィルターでは enable を使って未設定にし、sora へ送信しないようにしていたが、マルチ転送フィルターは転送フィルターの項目が階層で一つおりたので設定しようとしない限りは送らない想定 |
||
{ | ||
newFilter.Action = filter.action; | ||
} | ||
if (!string.IsNullOrEmpty(filter.name)) | ||
{ | ||
newFilter.Name = filter.name; | ||
} | ||
if (filter.priority >= 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unity に設定される int のデフォルト値が 0 で、priority に渡す値として 0 が有効な値である以上、ここで priority >= 0 のチェックする意味は無いです |
||
{ | ||
newFilter.Priority = filter.priority; | ||
} | ||
|
||
if (filter.rules != null) | ||
{ | ||
foreach (var ruleSet in filter.rules) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
if (ruleSet.data != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. インデントが深くなるのでガード条件にした方が良さそう
|
||
{ | ||
var ruleList = new List<Sora.ForwardingFilter.Rule>(); | ||
foreach (var rule in ruleSet.data) | ||
{ | ||
if (!string.IsNullOrEmpty(rule.field) && | ||
!string.IsNullOrEmpty(rule.op) && | ||
rule.values != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ユーザーがインスペクタで要素数を指定して作っている以上、ここは空文字列が来ても設定して Sora に送るほうが素直で良いので、ここら辺の条件はいらないです |
||
{ | ||
var newRule = new Sora.ForwardingFilter.Rule | ||
{ | ||
Field = rule.field, | ||
Operator = rule.op | ||
}; | ||
newRule.Values.AddRange(rule.values); | ||
ruleList.Add(newRule); | ||
} | ||
} | ||
if (ruleList.Count > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 空で送るテストすることを考えると、この条件は無くても良いです |
||
{ | ||
newFilter.Rules.Add(ruleList); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!string.IsNullOrEmpty(filter.version)) | ||
{ | ||
newFilter.Version = filter.version; | ||
} | ||
if (!string.IsNullOrEmpty(filter.metadata)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. json への変換は他の項目は別の場所で行なっていますが、複数の転送フィルターを設定することを考えてこちらで実行するようにしました |
||
{ | ||
newFilter.Metadata = filter.metadata; | ||
} | ||
|
||
if (newFilter.Action != null || | ||
newFilter.Name != null || | ||
newFilter.Priority.HasValue || | ||
newFilter.Rules.Count > 0 || | ||
newFilter.Version != null || | ||
newFilter.Metadata != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 仕様上、Action や Name、Priority に値が設定されてない場合でも ForwardingFilters は使えるはずなので、この分岐はダメそう |
||
{ | ||
config.ForwardingFilters.Add(newFilter); | ||
} | ||
} | ||
} | ||
sora.Connect(config); | ||
SetState(State.Started); | ||
Debug.LogFormat("Sora is Created: signalingUrl={0}, channelId={1}", signalingUrl, channelId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここ [ADD] のところと同じ内容だから削って良さそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確かに同じことが書いてあるだけでした。消します。